All Products
Search
Document Center

Cloud Shell:Use Alibaba Cloud CLI to manage data in OSS

Last Updated:Jun 24, 2024

Alibaba Cloud Shell integrates all features of ossutil, which is a command line tool provided to manage data in Object Storage Service (OSS). You can use the syntax of Alibaba Cloud Command Line Interface (CLI) to manage your data in OSS.

Background information

You can use Alibaba Cloud CLI to manage the following OSS data:

  • Buckets. For example, you can create, query, and delete OSS buckets.

  • Objects. For example, you can upload, download, query, copy, and delete OSS objects.

  • Parts. For example, you can query and delete OSS parts.

Procedure

  1. Start Cloud Shell.

    To start Cloud Shell, use one of the following methods:

    • Start Cloud Shell in the Alibaba Cloud Management Console

      In the Alibaba Cloud Management Console, click the Cloud Shell icon in the top navigation bar.

    • Start Cloud Shell as a standalone application

      Enter https://shell.alibabacloud.com in the address bar of a browser.

      You can open up to five Cloud Shell windows at the same time.

    Note

    When you connect to Cloud Shell for the first time, a virtual machine (VM) is created. The creation process takes at most 30 seconds. If you open multiple Cloud Shell windows, all the windows are connected to the same VM. The number of VMs does not increase when you open a new Cloud Shell window.

  2. Use Alibaba Cloud CLI to manage data in OSS.

    Cloud Shell is authorized to access your OSS service. You can use Alibaba Cloud CLI to manage data in OSS without the need to install other tools or configure other settings.

    Basic syntax:

    aliyun oss [command] [options and parameters]

    Examples:

    • Run the following command to create a bucket:

      aliyun oss mb oss://vmeixme
    • Run the following command to create a directory in a bucket:

      aliyun oss mkdir oss://vmeixme/horse/
    • Run the following command to query all buckets, objects, and parts in OSS:

      aliyun oss ls

    The following table describes all commands of Alibaba Cloud CLI.

    Command

    Description

    getallpartsize

    Queries the size of each part of incomplete multipart upload tasks in a bucket and the total size of these parts.

    appendfromfile

    Uploads a local file to an append object in OSS by using append upload.

    cors

    Adds cross-origin resource sharing (CORS) configurations to a bucket, or modifies, queries, and deletes the CORS configurations of a bucket.

    bucket-encryption

    Adds encryption configurations to a bucket, or modifies, queries, and deletes the encryption configurations of a bucket.

    lifecycle

    Adds lifecycle rule configurations to a bucket, or modifies, queries, and deletes the lifecycle rule configurations of a bucket.

    logging

    Adds logging configurations to a bucket, or modifies, queries, and deletes the logging configurations of a bucket.

    bucket-policy

    Adds bucket policy configurations to a bucket, or modifies, queries, and deletes the bucket policy configurations of a bucket.

    referer

    Adds hotlink protection configurations to a bucket, or modifies, queries, and deletes the hotlink protection configurations of a bucket.

    bucket-tagging

    Adds tagging configurations to a bucket, or modifies, queries, and deletes the tagging configurations of a bucket.

    website

    Adds static website hosting, redirection, or back-to-origin configurations to a bucket, or modifies, queries, and deletes the static website hosting, redirection, or back-to-origin configurations of a bucket.

    cat

    Exports object content to stdout.

    cors-options

    Tests whether a bucket allows a specified cross-origin request.

    cp

    Uploads, downloads, or copies objects.

    create-symlink

    Creates a symbolic link.

    du

    Obtains the capacity of a bucket or the size of a specified directory.

    hash

    Calculates the CRC-64 or MD5 value of a local file.

    help

    Queries the help information about a command. We recommend that you run the help command to query the information about how to run a specified command.

    listpart

    Lists the parts generated in an incomplete multipart upload task initiated for an object.

    ls

    Lists buckets, objects, or parts.

    mb

    Creates a bucket.

    mkdir

    Creates a directory in a bucket. In OSS, directory names are suffixed with a forward slash (/).

    object-tagging

    Adds tagging configurations to a bucket, or modifies, queries, and deletes the tagging configurations of an object.

    probe

    Monitors access to OSS. You can also run this command to troubleshoot issues that are caused by network faults or invalid parameter settings during the upload and download process.

    read-symlink

    Reads the description of a symbolic link.

    request-payment

    Configures the pay-by-requester mode for a bucket or queries the pay-by-requester configurations of a bucket.

    restore

    Restores an object from the frozen state to the readable state.

    rm

    Deletes buckets, objects, or parts.

    set-acl

    Configures the access control list (ACL) for a bucket or an object.

    set-meta

    Configures the metadata of an uploaded object.

    sign

    Generates a signed download URL for an object.

    stat

    Obtains the description of a specified bucket or object.

  3. Optional:Run the aliyun oss help command to query the help information about the commands that you can use in Alibaba Cloud CLI to manage OSS data.

    To obtain the help information about a specific command, use the following syntax:

    aliyun oss [command] help

    For example, to query the help information about the command that is used to create a directory in a bucket, run the following command:

    aliyun oss mkdir help