All Products
Search
Document Center

Simple Application Server:Create commands

Last Updated:Dec 24, 2024

Command Assistant enables routine O&M tasks on simple application servers, such as running automated O&M scripts, polling processes, resetting user passwords, installing or uninstalling software, updating applications, and installing patches. The Cloud Assistant commands can be batch or PowerShell commands for Windows servers and shell commands for Linux servers. You can specify custom parameters as variables in commands.

Usage notes

The maximum size of a Base64-encoded command is 18 KB.

Procedure

  1. Log on to the Simple Application Server console.

  2. In the left-side navigation pane, click Command Assistant.

  3. On the My Commands tab, click Create Command.

  4. In the Create Command panel, configure parameters as instructed.

    The following table describes the parameters.

    Parameter

    Description

    Command Type

    The type of the command.

    • Linux servers: Shell is supported.

    • Windows servers: Bat and PowerShell are supported.

    Command Name

    The name of the command.

    Command

    The command content.

    • Manually enter the command content. For example, you can enter the shell command ifconfig -s to view the brief information about the network interface controller (NIC) of the server.

    • Use AI Command Assistant: Press the Ctrl+I composite key or right-click the blank area in the Command field and then Click AI Command Assistant to invoke the AI Command Assistant. Follow the on-screen instructions to enter the command content, press Enter, and then click Insert Command.

      image

    You can also specify custom parameters in the {{key}} format such as {{parameterName}} in the Command field and enter parameter values such as ls -la /etc/profile in the Command Parameter field.

    You can create a maximum of 20 parameters. The parameters can contain digits and letters, and cannot be empty strings. Each parameter can be up to 64 characters in length.

    For more information, see Common commands.

    Used Parameters

    Specifies whether to use parameters.

    If you specify custom parameters in the {{key}} format in the Command field and turn on Use Parameters, you must enter values of the parameters in the Command Parameters field.

    Note

    You can create up to 20 parameters. The parameters can contain digits and letters, and cannot be empty strings. Each parameter can be up to 64 characters in length.

    Command Description

    The description of the command.

    We recommend that you enter information such as the purpose of the command to facilitate subsequent management and maintenance.

    Execution Path

    The working path of the command. You can specify a value for the parameter. Default working paths vary based on the operating systems of the servers on which the command is run.

    • For Linux servers, the default working path is the /root directory of the root user.

    • For Windows servers, the default working path is C:\Windows\system32.

    Timeout Period

    The timeout period of the command. If a task that runs the command times out, Command Assistant forcefully stops the task process.

    Unit: seconds. The default timeout period is 60 seconds. You can set the timeout period to a value from 10 to 86400 seconds (24 hours).

  5. Click Create Command.

Related operations

After you create a command, you can view the command, clone the command, and delete the command.

Operation

Description

Procedure

View a command

After you create a command, you can view the details of the command.

  1. Find the command that you want to view and click View Details in the Actions column.

  2. In the Command panel, view the details of the command.

Clone a command

You can quickly create new commands by modifying the parameter settings of existing commands.

  1. Find the command that you want to clone and click Clone in the Actions column.

  2. In the Clone Command panel, modify the parameter settings based on your business requirements and click Clone Command.

Delete a command

If you no longer require a command, you can manually delete the command.

  1. Find the command that you want to delete and choose image > Delete in the Actions column.

  2. In the Delete Command message, click Confirm.

Common commands

In this topic, Linux shell commands are used to describe common O&M commands, as shown in the following table.

Note

Custom parameters in a command make the command applicable to more scenarios. In the following sample commands, the parameters in the {{key}} format are custom parameters. When you run the commands, turn on Use Parameters and enter the values of the custom parameters in the Command Parameters field.

Operation

Sample command

Change the logon password of a server.

Run one of the following commands based on the operating system of your server:

  • Linux:

    echo "root:<yourPassword>"|chpasswd
  • Windows:

    net user "Administrator" "<yourPassword>"
Note
  • Replace <yourPassword> with a new password.

  • The password must be 8 to 30 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The password of a Windows server cannot start with a forward slash (/).

Add, remove, or modify user information

  • Add a user and set a password

    useradd -m -p {{password}} {{newUser}}
  • Change a password

    passwd {{password}}
  • Remove a user

    userdel {{newUser}}
  • Change a username

    usermod -l {{newUser}} -d /home/{{newUser}} -m {{previousUser}}

Enable or disable a firewall, and view the status of a firewall

  • Enable a firewall

    systemctl start firewalld
  • Disable a firewall

    systemctl stop firewalld
  • View the status of a firewall

    systemctl status firewalld

Install software

Note

In this example, NGINX is installed on the CentOS 7 operating system.

yum -y install nginx

Install CloudMonitor

ARGUS_VERSION=3.5.7 /bin/bash -c "$(curl -s https://cms-agent-cn-hongkong.oss-cn-hongkong-internal.aliyuncs.com/Argus/agent_install_ecs-1.7.sh)"
Important

Replace cn-hongkong in the command with the region ID of your Simple Application Server. For information about how to obtain the region ID of your simple application server, see Regions and Zones.

View the system configurations of a server

  • View basic configurations

    # View the information about activated network interface controllers (NICs).
    ifconfig
    # View the information about all NICs.
    ifconfig -a
    # View the brief information about NICs.
    ifconfig -s
    # View memory information.
    free -g
    # View memory information.
    cat /proc/meminfo
    # View operating system information, such as the version of the kernel.
    uname -a
    # View the usage of the hard disk.
    df -h
    # View the information about all hardware.
    dmidecode | more
  • View system processes or file details

    # View the information about all system processes.
    ps -ef
    # View the information about a specific system process. {{processName}} is the key of a custom parameter. You must set a value before you run the command.
    ps -ef | grep {{processName}}
    # View the details of a file.
    ls -la {{fileName}}
    # Query the path of a file.
    find {{path}} | grep {{fileName}}

What to do next

After you create a command, you can run the command on a specified server on the My Commands tab. For more information, see Run commands.