This topic describes how to install Alibaba Cloud CLI on macOS.
Procedure
You can use one of the following methods to install Alibaba Cloud CLI on macOS.
Install Alibaba Cloud CLI by using a PKG file (recommended)
Download the installation package for macOS.
Official website: You can download the latest version of Alibaba Cloud CLI.
GitHub: You can download a PKG file of any version of Alibaba Cloud CLI from the GitHub repository based on your business requirements.
Double-click the downloaded installation package and complete the installation as prompted.
Manually install Alibaba Cloud CLI
Download the installation package for macOS.
Download links:
Official website: You can download the latest version of Alibaba Cloud CLI.
GitHub: You can download a version of Alibaba Cloud CLI from the GitHub repository based on your business requirements.
In this example, the
aliyun-cli-macosx-latest-universal.tgz
installation package is downloaded to the$HOME/aliyun
directory. Run the following commands to go to the$HOME/aliyun
directory and decompress thealiyun-cli-macosx-latest-universal.tgz
file to the$HOME/aliyun
directory to obtain thealiyun
file:cd $HOME/aliyun tar xzvf aliyun-cli-macosx-latest-universal.tgz
Configure an environment variable.
Configure an environment variable by moving the file to the specified directory
Procedure
NoteBefore you perform this operation, run the
echo $PATH
command to check whether the/usr/local/bin
path exists in the value of the system environment variable PATH. Otherwise, configure an environment variable for thealiyun
file based on your business requirements.Run the following command to copy the
aliyun
file 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
ImportantA temporary environment variable configured by using the export command is valid only for the current session. When you exit the session, the configured environment variable is deleted.
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 youraliyun
file is stored.# Replace <CLI_PATH> in the command with the directory in which your aliyun 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 thealiyun
file is stored, the configuration is successful.
Configure a permanent environment variable by using a configuration file
Run the following commands to configure a permanent
PATH
environment variable.NoteBy default, the latest version of macOS uses the
Zsh
shell. You can run theecho $SHELL
command in the terminal and view the shell type in the result returned.If you use the
Bash
shell, you need to configure the environment variable in the.bash_profile
file. You need to replace<CLI_PATH>
in the command with the directory in which youraliyun
file is stored.# Replace <CLI_PATH> in the command with the directory in which your aliyun file is stored. echo 'export PATH=$PATH:<CLI_PATH>' >> ~/.bash_profile # Make the configuration file take effect. source ~/.bash_profile
If you use the
Zsh
shell, you need to configure the environment variable in the.zshrc
file. You need to replace<CLI_PATH>
in the command with the directory in which youraliyun
file is stored.# Replace <CLI_PATH> in the command with the directory in which your aliyun file is stored. echo 'export PATH=$PATH:<CLI_PATH>' >> ~/.zshrc # Make the configuration file take effect. source ~/.zshrc
Check whether the configuration is successful.
Run the
echo $PATH
command. If the returned result contains the directory in which thealiyun
file is stored, the configuration is successful.
Install Alibaba Cloud CLI by using Homebrew
Before you install Alibaba Cloud CLI, make sure that you have installed Homebrew on your macOS. If not, visit the official website of Homebrew to install Homebrew.
Run the following command to install Alibaba Cloud CLI:
brew install aliyun-cli
Verify the installation
Run the following command on the terminal to check whether Alibaba Cloud CLI is installed:
aliyun version
If a version number of Alibaba Cloud CLI similar to the following example is returned, Alibaba Cloud CLI is installed.
3.0.16