The third training in 2021 (commands that novices must master)

2.3 Commonly used system work commands
1. Echo command The
echo command is used to output the string or the extracted value of the variable in the terminal, the format is "echo [string| $variable]".
For example, the command to output the specified string "Linuxprobe.com" to the terminal screen is:
[root@linuxprobe ~]# echo Linuxprobe.Com
This command will display the following information on the terminal screen:
Linuxprobe.Com

2. date command The
date command is used to display and set the system time or date, the format is "date [option] [+specified format]".
[root@linuxprobe ~]# date
Mon Aug 24 16:11:23 CST 2017

The date command to view the current system time in the format of "year-month-day hour:minute:second" is as follows:

[root@linuxprobe ~]# date "+%Y-%m-%d %H:%M:%S"
2017-08-24 16:29:12

3. The reboot command is
used to restart the system, and its format is reboot.
[root@linuxprobe ~]# reboot

4. poweroff command The
poweroff command is used to shut down the system, and its format is poweroff.
[root@linuxprobe ~]# poweroff

5. wget command
wget command is used to download network files in the terminal, the format is "wget ​​[parameter] download address".

6. ps command The
ps command is used to view the process status in the system, the format is "ps [parameter]".
R (running): The process is running or waiting in the run queue. Serving
S (interrupt): The process is in sleep, and when a certain condition is formed or a signal is received, it leaves this state. Waiting for service
D (uninterruptible): The process does not respond to system asynchronous signals, and it cannot be interrupted even with the kill command. Can not be interrupted
Z (dead): the process has been terminated, but the process descriptor remain until the parent calls wait4 () system function after the release process. No service
T (stop): The process stops running after receiving a stop signal. Stopped service

7. top command The
top command is used to dynamically monitor information such as process activity and system load, and its format is top. Enhanced Windows Task Manager

Line 1: System time, running time, number of logged-in terminals (number of users in version 8), system load (the three values ​​are the average value within 1 minute, 5 minutes, and 15 minutes, respectively. The smaller the value, the greater the load low). The load value looks at
the second line from right to left : the total number of processes, the number of running processes, the number of sleeping processes, the number of stopped processes, and the number of dead processes.
Line 3: The percentage of resources occupied by users, the percentage of resources occupied by the system kernel, the percentage of process resources whose priority has been changed, the percentage of idle resources, etc. The data are all CPU data and displayed in percentage format. For example, "97.1 id" means that 97.1% of CPU processor resources are idle.
Line 4: Total physical memory, memory usage, free memory, and memory used as kernel cache.
Line 5: The total amount of virtual memory, the amount of virtual memory used, the amount of free virtual memory, and the amount of memory that has been loaded in advance.

8. The pidof command
pidof command is used to query the PID value of a specified service process, the format is "pidof [parameter] [service name]".
[root@linuxprobe ~]# pidof sshd
2156

9. The kill command
kill command is used to terminate a service process with a specified PID, the format is "kill [parameter] [process PID]".
[root@linuxprobe ~]# kill 2156

10. The killall command The
killall command is used to terminate all processes corresponding to a service with a specified name, in the format: "killall [parameter] [service name]".

2.4 The system status detection command actually mainly checks the name of the network card, the IP address after the inet parameter, the physical address of the network card (also known as the MAC address) after the ether parameter, and the number of received and sent data packets of RX and TX. And accumulated traffic (the information in bold below)
[root@linuxprobe ~]# ifconfig
eno16777728 (network card name): flags=4163 mtu 1500
inet 192.168.10.10 (IP address) netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80: :20c:29ff:fec4:a409 (MAC address) prefixlen 64 scopeid 0x20
ether 00:0c:29:c4:a4:09 txqueuelen 1000 (Ethernet)
RX packets 36 bytes 3176 (3.1 KiB) (receive data packets)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 4757 (4.6 KiB) (send data packets)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2. The uname command uname command is used to view the system kernel and system version and other information, the format is "uname [-a]". When using the uname command, the -a parameter is usually fixed to view the current system's kernel name, host name, kernel release version, node name, system time, hardware name, hardware platform, processor type, and operating system name. And other information.

[root@linuxprobe ~]# uname -a
Linux linuxprobe.com 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

3. The uptime command
uptime is used to view the system load information, the format is uptime.
The average load value refers to the pressure of the system in the last 1 minute, 5 minutes, and 15 minutes (the information in bold below); the lower the load value, the better, try not to exceed 1 for a long time, and do not exceed 5 in a production environment .
[root@linuxprobe ~]# uptime
22:49:55 up 10 min, 2 users, load average: 0.01, 0.19, 0.18
4. The free command
free is used to display the memory usage information in the current system, the format is "free [-h]".
[root@linuxprobe ~]# free -h
5. The who command
who is used to view the information of the user terminal currently logged into the host, the format is "who [parameter]".
[root@linuxprobe ~]# who
6. The last command
last command is used to view the login records of all systems, the format is "last [parameter]".
7. The history command is
used to display the commands that have been executed in the history, the format is "history [-c]"
[root@linuxprobe ~]# history
!Code number" to repeat a certain command
to clear the current user on the machine For the history record information of Linux commands executed on the command line, you can execute the following command:
[root@linuxprobe ~]# history -c
8. sosreport command
The sosreport command is used to collect system configuration and architecture information and output diagnostic documents in the format of sosreport.

2.5 Working directory switching command 1. pwd command The
pwd command is used to display the current working directory of the user, in the format "pwd [option]".

[root@linuxprobe etc]# pwd
/etc

2. cd command
cd command is used to switch the working path, the format is "cd [directory name]".
"Cd -" command to return to the last directory,
"cd.." command to enter the upper level directory,
"cd ~" command to switch to the current user's home directory,
or use "cd ~username" to switch to other User's home directory

3. ls command The
ls command is used to display file information in the directory, the format is "ls [option] [file] ".
The "-a" parameter can see all files (including hidden files), and the
"-l" parameter can view detailed information such as file attributes and size.
After integrating these two parameters, "-al" can view all files in the current directory and output the attribute information of these files
-d parameter to view directory attribute information
[root@linuxprobe ~]# ls -ld /etc
drwxr-xr- x. 132 root root 8192 Jul 10 10:48 /etc

2.6 Text file editing commands

The third training in 2021 (commands that novices must master)The third training in 2021 (commands that novices must master)1. cat command The
cat command is used to view plain text files (less content), the format is "cat [option] [file]".
-n parameter shows the number of lines

2. The more command The
more command is used to view plain text files (more content), in the format "more [option] file".
more Enter and go down one line of space and go down one page
cat short file
more long file

3. The head command is
used to view the first N lines of a plain text document, in the format "head [option] [file]".
[root@linuxprobe ~]# head -n 20 initial-setup-ks.cfg
4. tail command The
tail command is used to view the last N lines of a plain text document or continuously refresh the content, the format is "tail [option] [file]".
tail -n 20 file name view the last 20 lines of the
file tail -f file name view the latest log file in real time
5. The tr command is
used to replace characters in a text file, in the format "tr [original character] [target character]".
cat anaconda-ks.cfg | tr [az] [AZ]
Convert lowercase letters to uppercase letters | as pipe character
6. wc command The
wc command is used to count the number of lines, words, and bytes of the specified text. The format is "wc [parameter] text". Characters not statistical
parameters and action tables 2-10 wc of
parameters
effect
-l
displays only the number of rows
-w
display only the number of words
-c
display only the number of bytes
[linuxprobe the root @ ~] -l # WC / etc / the passwd
38 is / etc/passwd
7. stat command
The stat command is used to view the specific storage information and time of the file, the format is "stat file name" Three time states (in bold): Access, Modify, Change
ATIME The time of the last access to the file content
MTIME The last modification of the file The time of the content
CTIME The time when the file attribute was last modified

8. The cut command The
cut command is used to extract text characters by "column", the format is "cut [parameter] text".
cut -d: -f1 /etc/passwd
cut extract by column
-d: use colon as separator
-f1 first column
/etc/passed target name
9. diff command The
diff command is used to compare the differences between multiple text files, the format is "diff [parameter] file".
Use the diff --brief command to display the result of the comparison and determine whether the files are the same:

[root@linuxprobe ~]# diff --brief diff_A.txt diff_B.txt
Files diff_A.txt and diff_B.txt differ

Guess you like

Origin blog.51cto.com/15082285/2590602