This topic describes how to uninstall Alibaba Cloud CLI and provides important notes for the process.
Precautions
To avoid version conflicts and potential compatibility issues, always use the uninstallation method that matches your installation method. For example:
If you installed Alibaba Cloud CLI by using Homebrew, uninstall it by using Homebrew. We do not recommend using other methods for uninstallation.
If you installed Alibaba Cloud CLI in a custom directory on Linux or macOS, we recommend that you uninstall it from the CLI.
If you are not sure how or where Alibaba Cloud CLI was installed, try all the following methods to ensure a complete uninstallation.
Procedure
In the following steps, <script_path> is a placeholder. Before you run a command, replace it with the actual path to your script file.
Linux/macOS
Uninstall by using Homebrew
On macOS, run the following command to uninstall Alibaba Cloud CLI:
brew uninstall aliyun-cliUninstall from the CLI
Run the following command to delete the executable file of Alibaba Cloud CLI. You can also perform this action in the graphical user interface (GUI).
sudo sh -c "which aliyun | xargs -r rm -v"Remove the installation directory from the PATH environment variable.
NoteIf you did not use a custom installation directory when you installed Alibaba Cloud CLI, you can skip this step.
The following table lists common environment variable configuration files on Linux and macOS.
Shell type
Configuration file
Bash
~/.bashrc~/.bash_profile~/.profile/etc/profile
Zsh
~/.zshrc~/.zprofile/etc/zshenv/etc/zprofile/etc/zshrc
You can use a text editor or a CLI such as
grepto search for changes related to the Alibaba Cloud CLI installation directory and delete or comment out the relevant lines in the configuration file. For example, to search in~/.bashrc:grep "PATH" ~/.bashrc
Uninstall by using a Bash script
Create a script file and copy the following content into it.
Refer to the following examples to run the script and uninstall Alibaba Cloud CLI.
# Uninstall only the executable file. bash <script_path> # Uninstall the executable file and delete the configuration file. bash <script_path> -C # View help information for the script. bash <script_path> -h
Windows
Windows users can uninstall Alibaba Cloud CLI by using the following methods.
Uninstall from the GUI
In File Explorer, go to the Alibaba Cloud CLI installation directory and delete the executable file.
Press the
Windowskey and enter environment variables in the search box.In the search results, click Edit environment variables for your account to open the Environment Variables window.
In the User variables section, select the
Pathenvironment variable and click Edit.
In the Edit environment variable window, select the path to the Alibaba Cloud CLI installation directory and click Delete. This removes the path from the
Pathenvironment variable. Example directory:C:\ExampleDir. Replace this with the actual path.
Click OK in all related dialog boxes to save the changes.
Uninstall by using a PowerShell script
Create a script file and copy the following content into it.
Refer to the following examples to run the script and uninstall Alibaba Cloud CLI.
# Uninstall only the executable file. powershell.exe -ExecutionPolicy Bypass -File <script_path> # Uninstall the executable file and delete the configuration file. powershell.exe -ExecutionPolicy Bypass -File <script_path> -Clean # View help information for the script. powershell.exe -ExecutionPolicy Bypass -File <script_path> -Help
Delete the configuration file (Optional)
The configuration file for Alibaba Cloud CLI is located in the .aliyun folder within your user home directory. The location of the user home directory varies by operating system.
Windows:
C:\Users\<USERNAME>\.aliyunLinux or macOS:
~/.aliyun