Use! To invoke past commands.
!! Repeat the previous instruction
!a Repeat the previous instruction, led by a
!nubmer Repeat the previous instruction to record numbers in the history table
!-number Repeat the previous number instruction
Ailas abc= ' CD xxxxxxxxxxx/xxxxxxxx/xxxxxxxxxxxxx '
Unalias ABC
"" To see a string of characters as strings, you can translate special characters
" the character cannot be translated as a string.
• Ability to return results from command execution
Echo ' Uname-a '
Mathematical operations
$[] expressions within brackets are mathematically calculated
escape character \
Special meaning for canceling characters in the command line
Used to indicate the end of a line
end character ;
child Shell Activation Command ()
logical operators
&& Execute the following command after the execution of the current instruction is successful
|| The following command is executed after the execution of the current instruction fails
Login Shell
by default, the variable is changed underthe shell, Umask,alias is only valid for this login, and the default value will be restored once it is logged out. You need to change the configuration file for permanent entry.
Custom Landing Shell
Global settings file /etc/profile
/etc/bashrc
user settings file ~/.BASHRC
~/.profile
source./bash_profile Execution Environment variables
CTRL -D input has ended.
System Monitoring
uname Display System Information uname-a
Hostname Display host name hostname a change the hostname to a (temporary) if you want to change the configuration file permanently /etc/sysconfig/network
last list of recently logged in users
Lastlog List The user's last logon time and login terminal address
Free Check memory condition
Top Task Manager
Process
Instructions for querying a process
PS option ps-ef lists all processes of the current system Psaux
Pstree to display process relationships in a tree-like manner
Control process
Kill- Signal file
Kill-9 forced termination
Pkill Process Name
Kill sleep// equivalent to Ps-ef |grep sleep |awk|xargs|kill
Killall httpd// kills all processes, kills all http processes
the priority of the process, represented by a nice value
Nice with a nice value to run command nice-nnum command
Renice Changing the nice value of a running process
Renice-n PID
Nohup SH executes scripts in the background
Ctrl Z hangs a foreground process
FG Job Number The file foreground runs the BG job number to run the file background
/proc Directory
Shell Scripts Script
a shell script is a text file that contains a shell directive
Shell and oh ah this supports variables with simple syntax to complete batch work
How shell scripts support interaction, reading data from standard input at execution time
some of ING 's system work is done through shell scripting, such as system boot, service control.
Edit Shell script
General use VI Edit Script. Starting with # in the script indicates that the line is commented.
the first character of a script if the non- # representation is a bash script
The first character of a script if it is
in shell and Shell scripts, we allow ourselves to define variables and assign them values
Grammar variable Name = value
Export variable name variable becomes environment variable
Unset to cancel a variable definition
to read data into a database using read
Read username from standard input read-p "please xxxxxxx": U1
echo Output
run the shell script
SH path / script name
/ Path / script name
./ Path / script name
Conditional judgment
If condition ["$pass" = ' hostname '];
Then
elif conditions
Then
Else
Action
Fi
Case Expression in
Match value 1)
action ;;
Match Value 2)
action ;;
Esac
For variable in array
Do
Action
Done
While condition
Do
Action
Done
Until conditions
Do
Action
Done
X window System