Common commands are Cloud Assistant commands that Alibaba Cloud provides to all users. These commands are applicable to a variety of scenarios, such as software installation or uninstallation, instance status diagnostics, and key rotation. This topic describes how to view and run common Cloud Assistant commands.
Background information
Common commands are Cloud Assistant commands that Alibaba Cloud provides to all Alibaba Cloud users. These commands contain scripts or executable programs that are used to install Cloud Assistant plug-ins or complex scripts that are used to configure servers, conduct health or security checks, install applications and system patches, process files, modify system configurations, and manage services or applications.
Compared with custom commands, common commands are provided, published, and updated by Alibaba Cloud. After a common command is published, you can view the content of the command and run the command on Elastic Compute Service (ECS) instances to perform specific operations. For example, you can run common commands to upgrade Cloud Assistant Agent on Linux instances, determine whether to resize disks on Linux instances, or install Java on instances. After a common command is run on instances, you can view the execution progresses and results of the command. You can run common commands to complete complex configurations in an easy and quick manner, which improves the efficiency of O&M.
Procedure
You can use one of the following tools based on your business requirements to view and run common commands:
ECS console
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the ECS Cloud Assistant page, click the Common Commands tab.
You can use the common commands that are provided by Alibaba Cloud on the tab.
Find the common command that you want to run and click Run.
NoteOnly common commands of the latest versions are displayed on the ECS Cloud Assistant page. If you want to view and run a common command of an earlier version, click the ID of the command to go to the Command Details panel.
In the Run Command panel, configure parameters and click Run.
The following table describes the parameters.
NoteFor information about the parameters that are required to run common commands, see the Run a command in the ECS console section of the "Run a command" topic.
Section
Parameter
Description
Command Information
Command content
Click View command content to view the command.
Execution Plan
Select an execution plan for the command. Valid values:
Immediate execution
After the next startup of the system
After each system startup
Run on Schedule
For more information about how to configure this parameter, see the description of the parameter in Create and run a command.
Username
Enter a username to use to run the command on ECS instances. Example: root.
By default, Cloud Assistant commands are run by the root user on Linux instances and by the System user on Windows instances.
Timeout
Enter a positive integer in the range of 10 to 86,400. Unit: seconds. 86,400 seconds are equal to 24 hours. When the specified timeout period expires, the command process is forcefully terminated. The specified value is used as the timeout period of the command.
Command Parameters
If Command Parameters is displayed in the panel, enter a valid value for each required parameter.
NoteIf parameter description, default values, or valid values are provided, enter values as instructed. To run the command, you must specify required parameters.
Select Instance
N/A
Select one or more instances on which you want to run the command. The selected instances must be in the Running state and have Cloud Assistant Agent installed.
Select Managed Instances
N/A
Select one or more managed instances on which you want to run the command. The selected managed instances must be in the Normal state and have Cloud Assistant Agent installed.
NoteA managed instance is an instance that is not provided by Alibaba Cloud but is managed by Cloud Assistant. For more information, see Alibaba Cloud managed instances.
On the Command execution result tab, find the common command that is run and click View in the Actions column.
In the execution details panel, if Successful is displayed in the Execution Status column, you can view the execution results of the common command.
NoteIf the command execution failed, check the error message and troubleshoot the issue. For more information, see Check execution results and troubleshoot common issues.
API
Query common commands by calling an API operation.
You can call the DescribeCommands operation to query all common commands or query a specific common command by name.
When you query common commands, take note of the following parameters:
Name: the name of the command. For example, to query the ACS-ECS-DiskResize-Diagnostic-for-linux.sh common command in the China (Hangzhou) region, set this parameter to ACS-ECS-DiskResize-Diagnostic-for-linux.sh.
Provider: the provider of the common command. If you set this parameter to AlibabaCloud, all common commands that are provided by Alibaba Cloud are queried.
Run a common command by calling an API operation.
You can call the InvokeCommand operation to run the queried common command. In the request, set the
CommandId
parameter to the command name or command ID returned in Step 1. The name of each common command remains the same in different regions.When you run a common command, take note of the following parameters:
CommandId: the ID of the command. For common commands, you can set CommandId to a command name. Example: ACS-ECS-DiskResize-Diagnostic-for-linux.sh.
After the operation is called, you can obtain the value of InvokeId in the response, which is the task ID of the common command. Example:
t-hz02kwqc9pg****
. You can call the DescribeInvocations or DescribeInvocationResults operation to query the execution results of the common command.You can also view the command execution results in the execution details panel in the ECS console. In this example, view the command execution results in the execution details panel to determine whether to resize disks on Linux instances.
Alibaba Cloud CLI
Query common commands by using Alibaba Cloud CLI.
You can call the DescribeCommands operation to query common commands.
You can set the
Provider
parameter toAlibabaCloud
to query all common commands that Alibaba Cloud provides.If you set this parameter to a specific provider, all the common commands provided by the provider are queried.
In this example, the operation is called to query all common commands that Alibaba Cloud provides in the China (Hangzhou) region. Sample request:
aliyun ecs DescribeCommands \ --region 'cn-hangzhou' \ --RegionId 'cn-hangzhou' \ --Provider 'AlibabaCloud'
In this example, the operation is called to query the
ACS-ECS-DiskResize-Diagnostic-for-linux.sh
common command in the China (Hangzhou) region. The command is used to check whether to resize disks on Linux instances. Sample request:aliyun ecs DescribeCommands \ --region 'cn-hangzhou' \ --RegionId 'cn-hangzhou' \ --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh'
Run a common command by using Alibaba Cloud CLI.
Call the InvokeCommand operation to run a common Cloud Assistant command on one or more ECS instances.
In this example, the operation is called to run the
ACS-ECS-DiskResize-Diagnostic-for-linux.sh
common command. The command is used to check whether to resize disks on Linux instances. Sample request:aliyun ecs InvokeCommand --RegionId 'cn-hangzhou' \ --InstanceId.1 'i-bp1f4f6o8lv0wqof****' \ --InstanceId.2 'i-bp137qu6142s3mhm****' \ --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh' \ --Timed 'false'
After the operation is called, you can obtain the value of
InvokeId
in the response, which is the task ID of the common command. Example:t-hz03rj5u0jx****
. You can call the DescribeInvocations or DescribeInvocationResults operation to query the command execution results. Sample request:aliyun ecs DescribeInvocations --RegionId 'cn-hangzhou' \ --InvokeId 't-hz03rj5u0jx****'
You can also view the command execution results in the execution details panel in the ECS console. In this example, view the command execution results in the execution details panel to determine whether to resize disks on Linux instances.