Manage OSS data with Alibaba Cloud CLI in Cloud Shell

更新时间:
复制 MD 格式

Use the pre-installed Alibaba Cloud CLI in Cloud Shell to manage Object Storage Service (OSS) resources from your browser without local setup.

Overview

The Alibaba Cloud CLI provides the aliyun oss command suite, a wrapper for the ossutil 1.0 tool pre-installed in Cloud Shell. Available operations include:

  • Buckets: Create, list, delete, and configure buckets.

  • Objects: Upload, download, copy, move, and delete objects.

  • Parts: List and delete parts.

Prerequisites

Launch Cloud Shell before you begin. You can start it using either method:

Note
  • For security, log on as a Resource Access Management (RAM) identity (RAM user or role) instead of the Alibaba Cloud account. The RAM identity must have permissions for the target resources. For more information, see Identity-based policies.

  • Cloud Shell automatically configures CLI credentials based on your logged-on identity. Do not modify or delete the default credential configuration file.

  • The first session provisions a virtual machine (VM), which may take a few moments. Subsequent sessions start faster.

  • Up to five concurrent windows are supported, all sharing the same VM instance.

Getting started: Common examples

The following examples demonstrate common OSS operations.

  1. Create a bucket. Use the mb (make bucket) command. Bucket names must be globally unique. This example creates a Standard-class bucket named vmeixme.

    aliyun oss mb oss://vmeixme --storage-class Standard
  2. Create a directory. Use the mkdir (make directory) command. This example creates a directory named horse in the vmeixme bucket.

    aliyun oss mkdir oss://vmeixme/horse/
  3. List OSS resources. Use the ls (list) command. This example lists all buckets, objects, and parts, with the result limit set to 20.

    aliyun oss ls --limited-num 20
  4. Get help. Run aliyun oss --help to list all oss commands.

    For details on any command, append help:

    aliyun oss [command] help

    Example for mkdir:

    aliyun oss mkdir help

Command reference

The following tables list all available OSS commands.

Bucket commands

Command

Description

mb

Creates a bucket.

ls

Lists all buckets, objects, and parts in your account.

rm

Deletes buckets, objects, or parts in your account.

set-acl

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

cors

Manages cross-origin resource sharing (CORS) rules for a bucket.

lifecycle

Manages lifecycle rules for a bucket.

logging

Manages access logging for a bucket.

website

Configures static website hosting and back-to-origin settings for a bucket.

bucket-encryption

Manages encryption configurations for a bucket.

bucket-policy

Manages bucket policies.

referer

Manages hotlink protection configurations for a bucket.

bucket-tagging

Manages tags for a bucket.

request-payment

Configures or queries pay-by-requester settings for a bucket.

Object commands

Command

Description

cp

Uploads, downloads, or copies objects.

mkdir

Creates a logical directory (an empty object with a trailing slash).

stat

Displays metadata for a specified bucket or object.

sign

Generates a presigned URL for an object.

du

Displays the size of a bucket or the total size of objects in a specified directory.

set-meta

Configures the metadata of an object.

appendfromfile

Appends content to an appendable object.

cat

Outputs object content to stdout.

object-tagging

Manages tags for an object.

restore

Restores a frozen object to a readable state.

Other commands

Command

Description

help

Displays help information for a specific command.

listpart

Lists parts of an incomplete multipart upload task.

getallpartsize

Queries the details of all parts of an incomplete multipart upload.

hash

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

cors-options

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

create-symlink

Creates a symbolic link.

probe

Monitors OSS access and troubleshoots network or parameter issues during uploads and downloads.

read-symlink

Reads the description of a symbolic link.