Linux necessary commands! Environment variable

Environment variable

Variables are generally uppercase AGE=18

Insert picture description here

$A representative variable
$$ displays the process id number of the current program.
Command execution steps in Linux:
Step 1: Determine whether the user enters the command in absolute or relative path (such as /bin/ls), if it is, then directly carried out.
Step 2: The Linux system checks whether the command entered by the user is an "alias command".
Step 3: The Bash interpreter determines whether the user entered an internal command or an external command. If it is an internal command, execute it directly, if it is an external command, go to the next step.
Step 4: The system searches for the command file entered by the user in multiple paths.
"." means the current directory, and "/" is just a separator between the upper directory and the lower directory.

Important environment variables

Command execution steps in Linux:

Step 1: Determine whether the user enters the command (such as /bin/ls) in absolute path or relative path, and execute it directly if it is.
Step 2: The Linux system checks whether the command entered by the user is an "alias command".
Step 3: The Bash interpreter determines whether the user entered an internal command or an external command. If it is an internal command, execute it directly, if it is an external command, go to the next step.
Step 4: The system searches for the command file entered by the user in multiple paths.
1. Command alias:

alias command: Create an alias for the command. Format: alias alias=command.
unalias command: cancel the command alias. Format: unalias alias.Insert picture description here

Conditional test statement

[Conditional expression]. There are spaces on both sides, and the conditional test statement cannot match the pipe character.

Parameters used for file testing

Operator effect
-e Determine if it exists
-d Determine if it is a directory
-f Determine if it is a file
-r Do you have read permission
-x Do you have permission to execute

Logic test statement parameters (return 0 for success, return 1 for failure)

Insert picture description here

  1. Logical AND (&&): The following commands will be executed only after the current command is successfully executed;
  2. Logical OR (||): The following commands will only be executed after the previous command fails;
  3. Logical negation (!): The judgment result in the conditional test is reversed;

Escape character

\ Make a variable after the backslash into a simple string effect: elimination function
Insert picture description here

Single quotation mark ('') escapes all variables in it as a pure string effect: eliminates all functions, global escaping
Double quotation marks ("") retains the variable attributes, and does not escape the
backquote (``) The command returns the result after execution.
Insert picture description here
Available integer comparison operators
Insert picture description here

Insert picture description here

free check the current system memory

awk'{print $4}' takes the fourth parameter and only keeps the fourth column

= Compare strings are the same
! = Compare strings are not the same
-z Determine whether the content of the string is empty Determine whether the variable is used

User identity and file permissions

Scheduled task service program

Set up the scheduled task service of the server, and hand over the periodic and regular work to the system to complete automatically.
Planning tasks are divided into one-time planning tasks and long-term planning tasks

1.at command: used to set one-time scheduled tasks. Format: at [time]/[parameter].

Insert picture description here
atrm 2 delete the corresponding pending items
at -l view pending items,

The crond service enabled by default in Linux is a daemon that is used to periodically perform certain tasks or wait to process certain events. The crond service is implemented through the crontab command.
-e Create and edit scheduled tasks;
-l View current scheduled tasks;
-r Delete a plan pending item
-u Edit the scheduled task of the corresponding user (only available as an administrator)

Use crond to set the parameter format of the task: time-sharing day-month-week command. If some fields are not set, use an asterisk (*) to occupy the space.

Use crond -e to set the parameter field description of the task
Insert picture description here

Guess you like

Origin blog.csdn.net/SYH885/article/details/108739952