All Products
Search
Document Center

Alibaba Cloud CLI:Linux

Last Updated:Aug 26, 2024

This topic describes how to install Alibaba Cloud CLI on Linux.

Procedure

  1. Download the installation package of Alibaba Cloud CLI for Linux.

    You can download the installation package in one of the following ways:

    • Download the installation package of Alibaba Cloud CLI of the latest version from the official website.

    • Download the installation package of Alibaba Cloud CLI of a random version from GitHub based on your business requirements.

  2. In this example, the installation package named aliyun-cli-linux-latest-amd64.tgz is downloaded to the $HOME/aliyun directory. In this case, run the following command to change the current directory to the $HOME/aliyun directory and decompress the aliyun-cli-linux-latest-amd64.tgz file to the $HOME/aliyun directory to obtain the file named aliyun.exe:

    cd $HOME/aliyun
    tar xzvf aliyun-cli-linux-latest-amd64.tgz
  3. Configure an environment variable.

    Configure an environment variable by moving the file to a specific directory

    Procedure

    Note

    Before you perform this operation, run the echo $PATH command to check whether the value of system variable contains the /usr/local/bin directory. If not, configure a valid environment variable for the aliyun.exe file based on your business requirements.

    Run the following command to copy the aliyun.exe file and paste it to the /usr/local/bin directory:

    sudo cp aliyun /usr/local/bin

    If you are a root user, remove sudo from the command.

    Configure a temporary environment variable by using the export command

    Important

    A temporary environment variable configured by using the export command is valid only for the current session. After you exit the session, the configured temporary environment variable becomes invalid.

    • Run the following command to configure a temporary PATH environment variable. You need to replace <CLI_PATH> in the command with the directory in which the aliyun.exe file is stored.

      # Replace <CLI_PATH> in the command with the directory in which the aliyun.exe file is stored. 
      export PATH="$PATH:<CLI_PATH>"
    • Check whether the configuration is successful.

      Run the echo $PATH command. If the returned result contains the directory in which the aliyun.exe file is stored, the configuration is successful.

    Configure a permanent environment variable by using a configuration file

    Important

    After you configure an environment variable, restart your development tools or services, such as the integrated development environment (IDE). This ensures that the new settings take effect as expected.

    • Run the following command to configure a permanent PATH environment variable. You need to replace <CLI_PATH> in the command with the directory in which the aliyun.exe file is stored.

      # Replace <CLI_PATH> in the command with the directory in which the aliyun.exe file is stored. 
      echo 'export PATH=$PATH:<CLI_PATH>' >> ~/.bash_profile
      # Make the configuration file take effect.
      source ~/.bash_profile
    • Check whether the configuration is successful.

      Run the echo $PATH command. If the returned result contains the directory in which the aliyun.exe file is stored, the configuration is successful.

Verify the installation

Run the following command on the terminal to check whether Alibaba Cloud CLI is installed:

aliyun version

If the system displays a version number of Alibaba Cloud CLI similar to the following example, Alibaba Cloud CLI is installed.

3.0.16