All Products
Search
Document Center

Object Storage Service:Get started with ossutil

Last Updated:Feb 22, 2025

ossutil is a command-line tool for managing Alibaba Cloud Object Storage Service (OSS) on Windows, macOS, and Linux systems. It allows you to perform batch operations and automate tasks efficiently. This guide covers operations such as creating buckets, uploading and downloading files, listing files, and deleting files and buckets using the command line.

Note
  • This guide uses ossutil 2.0 as an example. ossutil 2.0 offers a comprehensive upgrade in features compared to ossutil 1.0. We strongly recommend using the latest version of ossutil 2.0. For information on ossutil 1.0, please refer to ossutil 1.0.

  • If you have already installed and configured ossutil 2.0, you can refer directly to ossutil 2.0 commands.

Prerequisites

Install ossutil

Linux

  1. Install the unzip tool.

    Alibaba Cloud Linux

    sudo yum install -y unzip

    CentOS

    sudo yum install -y unzip

    Ubuntu

    sudo apt install -y unzip
  2. Download the ossutil package.

    curl -o ossutil-2.0.6-beta.01091200-linux-amd64.zip https://gosspublic.alicdn.com/ossutil/v2-beta/2.0.6-beta.01091200/ossutil-2.0.6-beta.01091200-linux-amd64.zip
    Note

    This example downloads ossutil for a 64-bit Linux x86 system. For other systems, see Download ossutil.

  3. Extract the package in the directory where it was downloaded.

    unzip ossutil-2.0.6-beta.01091200-linux-amd64.zip
  4. Navigate to the ossutil-2.0.6-beta.01091200-linux-amd64 directory.

    cd ossutil-2.0.6-beta.01091200-linux-amd64
  5. Run the following command in the current directory.

    chmod 755 ossutil
  6. Enable global invocation of ossutil with the following command.

    sudo mv ossutil /usr/local/bin/ && sudo ln -s /usr/local/bin/ossutil /usr/bin/ossutil
  7. Verify the installation of ossutil by running the ossutil command.

    ossutil

    If ossutil's help information is displayed, the installation was successful.

Windows

  1. Install ossutil.

    1. Download the installation package for your system:

    2. Extract the .zip package to the target folder and navigate to the extracted directory as shown in the figure.

    3. Copy the path of the extracted ossutil folder to configure the system environment variable.

      1. Click the path bar of the current directory and copy the displayed path.

      2. Open the Environment Variables dialog box. In the System Variables section, find and double-click the Path variable. Click the New button, and then paste the copied path of the ossutil folder into the new entry box.

    4. Verify the installation of ossutil by running the ossutil command.

      ossutil

      If ossutil's help information is displayed, the installation was successful.

macOS

  1. Install ossutil.

    curl -o ossutil-2.0.6-beta.01091200-mac-arm64.zip  https://gosspublic.alicdn.com/ossutil/v2-beta/2.0.6-beta.01091200/ossutil-2.0.6-beta.01091200-mac-arm64.zip
    Note

    This example downloads ossutil for a 64-bit macOS ARM system. For other systems, see Download ossutil.

  2. Extract the package in the directory where it was downloaded.

    unzip ossutil-2.0.6-beta.01091200-mac-arm64.zip
  3. Navigate to the ossutil-2.0.6-beta.01091200-mac-arm64 directory.

    cd ossutil-2.0.6-beta.01091200-mac-arm64
  4. Run the following command in the current directory.

    chmod 755 ossutil
  5. Enable global invocation of ossutil with the following command.

    sudo mv ossutil /usr/local/bin/ && sudo ln -s /usr/local/bin/ossutil /usr/bin/ossutil
  6. Verify the installation of ossutil by running the ossutil command.

    ossutil

    If ossutil's help information is displayed, the installation was successful.

Configure ossutil

  1. Configure ossutil.

    ossutil config
  2. Set the path of the ossutil configuration file as prompted. Press Enter to use the default path.

    The following prompt is based on a Linux system.

    Please enter the config file name,the file name can include path(default /root/.ossutilconfig, carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):
  3. Enter the AccessKey ID you created earlier when prompted.

    Please enter Access Key ID [****************id]:LTAI****************
  4. Enter the AccessKey Secret you created earlier when prompted.

    Please enter Access Key Secret [****************sk]:R6vg*********************
  5. Enter the region ID of the OSS data center when prompted.

    Please enter Region [cn-hangzhou]:cn-hangzhou

    This guide uses Hangzhou as an example. For other regions' IDs, see OSS regions and endpoints.

  6. If you do not need to customize the endpoint, press Enter to skip this step. By default, the public endpoint corresponding to the region ID is used. For instance, if the region-id is set to cn-hangzhou, the default public endpoint is https://oss-cn-hangzhou.aliyuncs.com. To customize the endpoint, enter your specific endpoint information.

    Please enter Endpoint (optional, use public endpoint by default) [None]: https://oss-cn-hangzhou.aliyuncs.com

Example

  1. Create a bucket.

     ossutil mb oss://examplebucket

    If the output is similar to the following, the bucket named examplebucket has been created.

    0.668238(s) elapsed
  2. Upload a file to the bucket.

    1. Create a local file named uploadFile.txt.

      echo 'Hello, OSS!' > uploadFile.txt
    2. Upload the file to the bucket named examplebucket.

      ossutil cp uploadFile.txt oss://examplebucket

      If the output is similar to the following, the file has been uploaded to examplebucket.

      Success: Total 1 file, size 12 B, Upload done:(1 objects, 12 B), avg 44 B/s
      
      0.271779(s) elapsed
  3. Download a file.

    Download the sample file uploadFile.txt from examplebucket to the local folder named localfolder.

    ossutil cp oss://examplebucket/uploadFile.txt localfolder/

    If the output is similar to the following, the file has been downloaded to the local folder named localfolder.

    Success: Total 1 object, size 12 B, Download done:(1 files, 12 B), avg 74 B/s
    
    0.162447(s) elapsed
  4. List files in examplebucket.

    ossutil ls oss://examplebucket

    If the output is similar to the following, the files in examplebucket are listed.

    LastModifiedTime                   Size(B)  StorageClass   ETAG                                  ObjectName
    2024-11-26 14:35:29 +0800 CST           12      Standard   1103F650EB2C292D179A032D2A97B0F5      oss://examplebucket/uploadFile.txt
    Object Number is: 1
    
    0.124679(s) elapsed
  5. Delete uploadFile.txt from examplebucket.

    ossutil rm oss://examplebucket/uploadFile.txt

    If the output is similar to the following, uploadFile.txt has been deleted from examplebucket.

    0.295530(s) elapsed
  6. Delete examplebucket.

    ossutil rb oss://examplebucket

    If the output is similar to the following, examplebucket has been deleted.

    0.478659(s) elapsed

References

For more information about common issues during the use of ossutil, see ossutil 2.0 FAQ.