All Products
Search
Document Center

Object Storage Service:Get started with ossutil

Last Updated:Jan 07, 2025

With ossutil, you can efficiently manage Alibaba Cloud Object Storage Service (OSS) on Windows, macOS, and Linux systems through the command line and perform batch operations or automate tasks. This topic describes how to create a Bucket, upload a file, download a file, list a file, delete a file, and delete a Bucket through the command line.

Note
  • This topic takes ossutil 2.0 as an example. Compared with ossutil 1.0, ossutil 2.0 has undergone a comprehensive feature upgrade. We strongly recommend that you use the new version of ossutil 2.0. If you want to view content related to ossutil 1.0, we suggest you refer to ossutil 1.0.

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

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.5-beta.11291800-linux-amd64.zip https://gosspublic.alicdn.com/ossutil/v2-beta/2.0.5-beta.11291800/ossutil-2.0.5-beta.11291800-linux-amd64.zip
    Note

    In this example, ossutil is downloaded for a 64-bit Linux x86 system. For download links for other systems, see download ossutil.

  3. Run the following command in the directory where the package is downloaded to extract it.

    unzip ossutil-2.0.5-beta.11291800-linux-amd64.zip
  4. Navigate to the ossutil-2.0.5-beta.11291800-linux-amd64 directory.

    cd ossutil-2.0.5-beta.11291800-linux-amd64
  5. Run the following command in the current directory.

    chmod 755 ossutil
  6. Run the following command for global invocation of ossutil.

    sudo mv ossutil /usr/local/bin/ && sudo ln -s /usr/local/bin/ossutil /usr/bin/ossutil
  7. Verify whether ossutil is successfully installed.

    ossutil

    If the help information of ossutil is returned, the installation is successful.

Windows

  1. Click Windows x86 64bit, Windows x86 32bit, or Windows x86 64bit to download the installation package based on the configuration of your computer .

  2. Extract the tool and double-click to run the ossutil.exe file.

  3. Verify whether ossutil is successfully installed.

    ossutil

    The help information of ossutil is returned.

macOS

  1. Install ossutil.

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

    In this example, ossutil is downloaded for a 64-bit macOS ARM system. For download links for other systems, see download ossutil.

  2. Run the following command in the directory where the package is downloaded to extract it.

    unzip ossutil-2.0.5-beta.11291800-mac-arm64.zip
  3. Navigate to the ossutil-2.0.5-beta.11291800-mac-arm64 directory.

    cd ossutil-2.0.5-beta.11291800-mac-arm64
  4. Run the following command in the current directory.

    chmod 755 ossutil
  5. Run the following command for global invocation of ossutil.

    sudo mv ossutil /usr/local/bin/ && sudo ln -s /usr/local/bin/ossutil /usr/bin/ossutil
  6. Verify whether ossutil is successfully installed.

    ossutil

    The help information of ossutil is returned.

Configure ossutil

  1. Configure ossutil.

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

    The following prompt takes a Linux system as an example.

    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 previously created AccessKey ID as prompted.

    Please enter Access Key ID [****************id]:LTAI****************
  4. Enter the previously created AccessKey Secret as prompted.

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

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

    This topic takes the Hangzhou region as an example. For the IDs of other regions, see OSS regions and endpoints.

Example

  1. Create a bucket.

     ossutil mb oss://examplebucket

    The following output indicates that examplebucket is created.

    0.668238(s) elapsed
  2. Create a local file and upload it to the bucket.

    echo 'Hello, OSS!' > uploadFile.txt
    
    ossutil cp uploadFile.txt oss://examplebucket

    The following output indicates that the file is 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 uploaded sample file uploadFile.txt from examplebucket to localfolder.

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

    The following output indicates that the file is downloaded to 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

    The following output indicates that 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

    The following output indicates that uploadFile.txt is deleted from examplebucket.

    0.295530(s) elapsed
  6. Delete examplebucket.

    ossutil rb oss://examplebucket

    The following output indicates that examplebucket is deleted.

    0.478659(s) elapsed