Teaching wife to learn Linux operation and maintenance Linux common command Guide

tips: Next to the previous article, Linux Command Guide


2.4 File Unzipping

2.4.1 Guanxuan linux Compression Tool: tar

The basic command format for tar is

tar [parameter options] [file or directory]

The commands we've learned before always have parameter options - - the tar command is a bit special, plus or minus, for example, tar -z can be written as tar z.

Common tar commands:

Tar-zcvf [compressed package name] [packaged file or directory]
# [Compressed package name] is usually tar.gz suffix
 # z: Compression or decompression via gzip
 # c: Create a new tar package
 # v: Display command execution process
 # f: Specify the name of the compressed file
 # t: View tar package content without decompressing

tar tvf [compressed package]
# View the contents of the compressed package without decompressing

tar zxvf [compressed package]-C [decompression path]
# To change c of the compression parameter to x is to decompress it.
#- C: Specify the decompression path without - C to the current directory

Common command examples:

# Prepare point data first

cd ~
# Return to the user root directory

mkdir -p /var/www/yaojiaxiaoyuan/html
# Create multilevel directories

touch /var/www/yaojiaxiaoyuan/html/yaomaomao{01..10}.html
# Create multiple files in batch in the above directory

tar zcvf www.tar.gz /var/www/yaojiaxiaoyuan/html
# Packing directory / var/www/yaojiaxiaoyuan/html into www tar package

mkdir /var/www/yaojiaxiaoyuan/html/test

find /var/www/yaojiaxiaoyuan/html ! -type d| xargs tar zcvf www2.tar.gz
# Find files that are not directories under / var/www/yaojiaxiaoyuan/html and package them as www2.tar.gz
# Combine packaging according to the commands learned by find
# The -- exclude parameter of the tar command also has the function of excluding packaging, so it can be studied by itself without further elaboration.

tar -tvf www2.tar.gz
# Do not decompress to view files in compressed package www2.tar.gz

mkdir ./yao/ yao2

tar zxvf www.tar.gz -C ./yao/
# Unzip www.tar.gz to the yao directory
# You can see that even var is packed in.

If you don't want to pack, what about multi-tier, pack directly from cd to the directory you need to pack.

2.4.2 gzip

gzip can only pack files, not directories.

gzip packages the file and deletes the source file.

gzip parameters:

gzip [parameter options] [to compress files or packages]

#- d: decompression
 #- v: Display decompression process
 #- l: List compressed file content information
 #- c: Do not change the original file
 #- r: Recursively compress all files in the directory
 #- t: Check the integrity of compressed files
 #- Number <1-9>: Specify the compression rate, the larger the value, the higher the compression rate, default to 6

Examples of Common Commands for gzip:

cd /var/www/yaojiaxiaoyuan/html 

gzip *.html
# Packing all html files, you can see that html is compressed into gz files and disappeared.

gzip -l *.gz
# Presentation of information in compressed packages without decompression

gzip -dv *.gz
# Unzip gz file

It can be found that the gz package disappeared after decompression. How do I keep the source files?

echo  'Try' >> yaomaomao01.html 
# First add a point to the yaomaomao01.html file, where echo works like sed

gzip -c yaomaomao01.html > 01.gz
# Compress yaomaomao01.html to 01.gz using the - c +redirection symbol, and do not delete the source file. The same is true for decompression.

gzip -dc 01.gz > 01.html
# Decompress 01.gz to 01.html, and you can see that the source file 01.gz still exists.

Extension: You can view compressed files using extensions such as zcat, zgrep, zless, zdiff, as well as commands such as cat, grep, less and diff, as shown in Figure 1:

zcat 01.gz

gz can't compress directories, as we said at the beginning, the error is as follows:

gzip test

# ==>> gzip: test is a directory -- ignored

2.4.3 zip/unzip zip

zip compression format, windows, linux, mac are common compression format, and like tar, can compress directories.

zip yao.zip *
# Compress all files in the current directory

However, such packaging does not compress files under subdirectories, but only the subdirectories themselves, as shown in the figure:

cd test

touch test01.txt

cd ../

zip yao2.zip *

Like other commands, zip has a - r parameter that can be compressed recursively

 zip -r yao2.zip *
 # ==>>  adding: test/test01.txt (stored 0%)

There are already compressed packages in the current directory. When you want to pack this directory, you don't type in the last compressed packages and exclude them. How do you pack them? Using the - x parameter:

zip -r  yao3.zip * -x yao2.zip

Summary, zip packaging methods, and three parameters:

zip yao2.zip *
# General packing

zip -r  yao3.zip *
# Recursive packing

zip -r  yao3.zip * -x yao2.zip
# Recursive packaging, excluding a file

zip -rq  yao4.zip * 
# Recursive Packing, No Compressed Information Displayed

# Parametric, general compression
# - r: Recursive compression
# - x: Exclude a file compression
# - q: No compressed information is displayed unzip

unzip can decompress ZIP format files packaged by zip commands or other software packages such as rar, 360 compression on windows.

View the compressed file without decompressing:

unzip -l yao.zip

Specify directory decompression:

unzip -d yao01 yao.zip
# Unzip to the test folder
# - d: Specify a directory, create a directory without it, extract part of the information===> create: yao01/test/
# Unzip to the current folder by default without the - d parameter
# - o: When decompressing, we do not prompt whether to overwrite the file; if we decompress to the current directory now, we will prompt whether to overwrite it, because the file already exists, using - O can overwrite it directly
# - v: Show details of decompression

2.4.4 7za

7z is also an efficient compressed file format. Common commands for 7z are as follows.


7za a -r yao.7z *.html
# Compress all html into yao.7z packages
# a: add files and directories
# -r: recursion

View the internal information of the file without decompressing:

7za l yao.7z
# l: Undecompressed view


7za x yao.7z -r -oyao7z
# X: Unzip, x can also be decompressed by replacing e with x; but in general, the full path is decompressed by X and x, and all files are decompressed into a directory by e
# - r: Recursive decompression subdirectory
# - o: Specify the decompressed directory. Note that there is no space between the - O parameter and the directory. This is a strange point.

2.5 Users, Files and Permissions

2.5.1 Privilege Upgrade: su and sudo

When it comes to users and privileges, we have to start with an unavoidable command: su and sudo.

The common point between su and sudo is that commands can be executed with another user privilege.

The difference is that sudo does not need su to switch to another user.

Switch users, su's common commands:

# To see which user you are, we can see that it's root logged in.

su yao
# No password is required for root user to switch to normal user

su root
# Ordinary users need to enter passwords to switch back to root
# Tips: Su root = su, Su switching root does not require input of root username
# Note: Although this switch can be successful, the environment variable is still the original user, so use the following command to switch

su - yao
# su - [username], which can be switched to the corresponding user, but also the environment variables after login can be switched together

In fact, su can also execute commands without switching the past, just adding a parameter - c:

su - yao -c 'pwd'
# Using yao to execute pwd commands

As you can see, the implementation was successful and the yao home path was returned correctly.

But after all, this method is not as convenient as sudo. Next, let's look at sudo without switching users.

su - yao
# Switch to Ordinary User Logon

# Check if the switch is successful

ls /root
# Access the root folder

As you can see, there is no permission. What should I do? sudo ah.

sudo ls /root
# Visit the root directory and enter the login password of the yao user.

Can all users use sudo? Of course not. Let's look at the users who give sudo permission:

sudo -l
# View current user's authorized sudo permissions

How to grant sudo permission?

Add users to the / etc/sudoers file

sudo cat /etc/sudoers

It's OK to use vi or sed, but it's better to use visudo.

sudo visudo
# root users do not use sudo

visudo is specially designed to edit / etc/sudoers files. It also has the function of grammar checking. Add your sudo users as soon as possible.

2.5.2 User additions and deletions: useradd, usermod, userdel Users added: useradd, passwd

Most commonly used, add users without any parameters:

useradd wfy
# New user wfy

passwd wfy
# Set the password. The password is typically case plus number and a special character.

passwd tips, a command to set user passwords:

echo "123456" | passwd --stdin wfy
# stdin: Password can be obtained from standard input
# This command is useful for batch password modification
# In addition, there is a chpasswd command that can also batch password changes

passwd password expiration alert policy:

passwd -n 7 -x 60 -w 10 -i 30 wfy
# Password cannot be changed within 7 days. Password must be changed after 60 days. Users should be notified 10 days before expiration. Users should not be allowed to log in 30 days after expiration.
# - n: 7 denotes the number of days a password cannot be changed
# - x:60 denotes the number of days a password must be changed
# - w:10 means 10 days notice before expiration
# - i: 30 means no login for 30 days after expiration

When useradd does not take any parameters, the system will first read / etc/login.defs (user definition), / etc/deault/useradd (user default configuration) files, and then add users to / etc/passwd (password file), / etc/group (user group) files at the same time according to the rules set therein.

After that, you can go to the / home directory and see that the home directory belonging to this user has been created.

cd /home/wfy

chage -l wfy
# View User Validity Period

View user ownership information:

id wfy
# This information is actually in / etc/passwd and can be viewed and compared with grep wfy /etc/passwd.
# uid: User id
# gid: user group id

Let's look at the role of gid when we talk about group.

Prohibit login user creation:

useradd -s /sbin/nologin ftp_ymm
# - s: specify the shell for user login, / sbin/nologin means no login, middleware such as ftp deployment is often used

useradd -M -s /sbin/nologin nginx_wfy
# Middleware such as nginx, mysql, etc. is often deployed
# - M: Do not create home directories

Other parameters:

useradd -u 806 -s /bin/sh -c "This is the test user." -G root -e "2019/12/21" -f 2 -d /tmp/wfy test_wfy
# - u: Specify uid
# - c: User Description
# - G: Setting User Groups
# - e: Set expiration time
# - f:2 denotes suspension of rights for two days after expiration
# - d: User's home directory at each login

tail -1 /etc/passwd
# Looking at the last line of the passwd file, you can see the user information you just added

tail -1 /etc/shadow
# Looking at the last line of the / etc/shadow file, you can see the parameter 2 just added to - f.

Extension: using the useradd -D parameter is to modify the user's initial configuration file: /etc/deault/useradd, to see what this file has.

[root@VM_0_3_centos wfy]# cat /etc/default/useradd

# useradd defaults file
# Depending on the USERGROUPS_ENAB parameter of / etc/login.defs, if no, it is controlled here
# Build the user's home directory in / home
# Whether to enable user suspension of state-owned enterprises, -1 means not to enable
# User termination date, not set to indicate not enabled
# The default shell type used by new users
# Family directory default file storage path, when adding users, copy from this configuration directory in the past
# Create mail files

Use useradd-D to modify it. Of course, make a backup first.

cp /etc/default/useradd{,.bak} 
# Make a backup.

cd /etc/default
# You can see the creation of useradd.bak file

useradd -D -s /bin/sh
# - D: Change the / etc/default/useradd file
# - s: Change the default shell
# - b: Definition home directory
# - e: Set user expiration date
# - f: suspension of power several days after expiration
# - g: Setting up user groups

diff /etc/default/useradd{,.bak}

You can see the contrast effect. User Modification: usermod

Most of the parameters of usermod are the same as useradd, but only one modification is added. The different parameters are as follows:

usermod -l  wfy2 wfy
# Change the user's login name to wfy 2
# - l: Modify the user name
# - L: lock, lock the user password
# - U: unlock, unlock password
# - a: Additional user groups, with - G parameters

Replace useradd with usermod, other parameters unchanged, to modify the user information

usermod -u 806 -s /bin/sh -c "Modified the test user" -G root -e "2019/12/21" -f 2 -d /tmp/wfy test_wfy

grep test_wfy /etc/passwd

grep test_wfy /etc/shadow User Delete: userdel
userdel -r test_wfy
# - r: Delete user and home directories
# - f: Force the deletion of users even if they are logged in
# Home directories will not be deleted without deleting the - r parameter

Note: userdel is not used in practice, but user information is annotated in / etc/passwd.

2.5.3 User View: id, w, who, whoami, last

id, view user id information:

id wfy
# Display the uid and gid information of wfy

w, most commonly used, view logged-in user information:

# Display all logged-in user information
# The meaning of the display field is as follows
# USER: User
# tty: User tty name
# FROM: Where did you log in?
# LOGIN: Login time
# IDLE: Terminal idle time
# JCPU: Total time for all processes and subprocesses on the terminal to use the system
# PCPU: System time used by active processes
# WHAT: Process executed by the current user

who views all logged-in user information:

# Display logged-in user information, slightly different from w

users view all logged-in user names:

# Show users only

whoami views the current logged-in user information:

# View the currently logged-in username


# Display user login list, read / var/log/wtmp

last -10
# Display login information for the last 10 times

last root -10
# Display the last 10 login messages for root users

# Display user login failure information, read / var/log/btmp

lastb -10
# Show the latest 10 user login failure messages

lastb root -10
# Show root user login failure information, the latest 10

# Show all user's latest login record, read / var/log/lastlog

2.5.4 File permissions: chown, chmod Change File User Group: chown

Common chown commands are as follows:

cd ~
# Return to the root home directory

chown wfy wfy.txt
# Change wfy.txt to wfy

chown wfy:wfy wfy2.txt
# Change the user of wfy2.txt to wfy and the user group from root to wfy

chown -R wfy:wfy yao
# Empower the yao directory and its subdirectories to wfy
# You can see that the var directory page under yao is empowered to wfy, the user and user group Change file permissions: chmod

chmod can change the permission scope of files and directories. It has two empowerment modes: 1) using permission letters + operators; 2) using numbers.

Common command examples:

chmod 777 wfy.txt
# Change wfy.txt permissions to be accessible to all

Before amendment:

After amendment:

7 stands for rwx, and 777 stands for rwxrxrwx.

  1. "r" = 4, readable permissions; directories, subdirectories and their files are accessible.
  2. "w" = 2, writable permission; can modify the file content, directory name.
  3. "x" = 1, executable privileges; directories cannot be accessed without x privileges, and sh script files cannot be executed without X.
  4. "-" = 0, no permission.

Give directory read-only permissions:

chmod -R 555 yao
# 5 = 4 + 0 + 1, r-x, readable and executable permissions, but cannot be modified. Execute to see if the effect is the same as expected.

You can see that the first character is d, D represents the directory, followed by nine characters are r-x (sovereign limit), r-x (group authority bit), r-x (other user authority bit).

In addition, there is a commonly used empowerment mode, for + x, which gives executable permissions to files and is generally used to execute shell scripts:

chmod +x [script name].

There are generally four ways to execute shell scripts. The most common way is to use the following commands to execute after empowering + x:

/ script name.sh

There are three other ways:

/ script name.sh
 # There is a space after that.

Sorce script name.sh

SH script name.sh

Of course, it can also be used to execute txt files as follows:

. wfy.txt


sh wfy.txt

As you can see, our wfy.txt file is not a shell file, and no command can be found to execute it. The next shell introduction will tell you how to write the script file of. sh.

Note: Ordinary users need r privileges to execute, but root does not.

2.6 Resource Monitoring and Management

2.6.1 Virtual File Management System: proc

When it comes to resource management, the / proc folder is a directory that linux has to say.

ls /proc

You can see the digital folder of the red box circle in the red box / proc directory, which is actually where all the process files in our linux system are stored. Every time a process is generated, there will be a corresponding folder here, which is the pid we will often deal with in the future.

Many inux commands call files in this directory to display system-related information. For example, memory, cpu and other information.

Why can the files under proc store memory, processes, and cpu, which have nothing to do with disk files?

Because proc is actually a pseudo file system, or virtual file system. We said at the beginning of the article that everything in linux exists in the form of files, which is done by proc.

For users and applications, they can get some information of the system from proc, and even change some parameters of the kernel.

The contents of files in proc are not entirely unchanged. They will change with the change of system process. When users read them, the proc file system dynamically reads the required information from the system core and submits it.

Some of our common commands use the following files, such as disk, cpu, memory-related.

/proc/cmdline Kernel command line, core startup parameters
/proc/cpuinfo cpu related information
/proc/devices Mount equipment
/proc/Loadavg load balancing
/proc/meminfo Memory information
/proc/mounts Loading the file system
/proc/stat Comprehensive Statistical Status Table
/proc/swaps Exchange space table
/proc/version Kernel version
/proc/uptime System uptime

Refer to this article for a detailed description of the / proc directory. https://www.cnblogs.com/aofo/p/6151266.html

There's no need to go into proc, just know about it.

Next, let's look at some basic commands about disk, network, cpu, and memory.

2.6.2 Disk Space Monitor: df

df command can be said to be one of the most commonly used commands on linux, because once the disk space is insufficient, there will be a variety of failures, the database, applications may be paralysed.

Common command examples:

[root@VM_0_3_centos ~]# df -h
# Display disk space size in a human-readable manner

//File system capacity used Available% mount point
/dev/vda1        50G   43G  4.3G   91% /
devtmpfs        1.9G     0  1.9G    0% /dev
tmpfs            10G  666M  9.4G    7% /dev/shm
tmpfs           1.9G  324K  1.9G    1% /run
tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
tmpfs           380M     0  380M    0% /run/user/1005
tmpfs           380M     0  380M    0% /run/user/0

[root@VM_0_3_centos ~]# df -i
# - i: Display the usage of inode
# linux files have a limit on the number of inode files, once no inode is available, no new files can be generated, and "No space left on device" will be reported when disk space is not full. The solution is to delete useless (several days ago) small files or log files.

//File System Inode Used (I) Available (I) Used (I)% Mount Points
/dev/vda1      3276800  215486 3061314       7% /
devtmpfs        482932     308  482624       1% /dev
tmpfs           485254     258  484996       1% /dev/shm
tmpfs           485254     354  484900       1% /run
tmpfs           485254      16  485238       1% /sys/fs/cgroup
tmpfs           485254       1  485253       1% /run/user/1005
tmpfs           485254       1  485253       1% /run/user/0

[root@VM_0_3_centos ~]# df -Th
# - T: View file system types
# The mount disk / dev/vda1 file system type displayed locally is ext3

//File System Type Capacity Used Available% Mount Points
/dev/vda1      ext3       50G   43G  4.3G   91% /
devtmpfs       devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs          tmpfs      10G  666M  9.4G    7% /dev/shm
tmpfs          tmpfs     1.9G  324K  1.9G    1% /run
tmpfs          tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
tmpfs          tmpfs     380M     0  380M    0% /run/user/1005
tmpfs          tmpfs     380M     0  380M    0% /run/user/0
2.6.2 Memory Space Monitor: free

A computer, server, memory, storage (disk), processor (cpu), and operating system are the most basic components.

free is the command used to monitor linux system using memory.

Common command examples:

[root@VM_0_3_centos ~]# free -h
# Display memory usage in human readable mode, automatically convert to KB, MB, GB according to actual size

             total        used        free      shared  buff/cache   available
Mem:           3.7G        275M        144M         48M        3.3G        3.1G
Swap:          2.0G        658M        1.4G

Mem is physical memory usage, Swap is virtual memory usage (usually partitioning a portion of disk space as virtual memory).

total: total memory; 3.7G is generally 4G memory machine.

Used: Memory is used.

free: free memory.

Shared: shared memory.

Buffer / cache: Cache, 3.3G.

Available: available memory.

When there was no available display field in the past, we usually used the total amount of free + buff/cache as available memory.

The feature of linux system is to cache unused physical memory, because it must be assumed that free 144M memory is the real system's remaining memory. So the current available memory is available: 3.1G.

Common command 2: Query memory regularly

free -hs 5
# Display memory usage every 5 seconds, ctrl + c terminal
# - s: Displays memory usage at specified intervals in seconds

[root@localhost ca_ga]# free -hs 5
              total        used        free      shared  buff/cache   available
Mem:            62G         27G        359M         65M         34G         34G
Swap:           31G        6.7G         25G

              total        used        free      shared  buff/cache   available
Mem:            62G         27G        348M         65M         34G         34G
Swap:           31G        6.7G         25G

              total        used        free      shared  buff/cache   available
Mem:            62G         27G        354M         65M         34G         34G
Swap:           31G        6.7G         25G


2.6.3 Network Detector: ping

The ping command is similar to the ping command typed by cmd under windows. It is used to detect whether the network between hosts is smooth.

Common command examples:

ping www.baidu.com
# ping domain name or ip, will always display ping results, ctrl + c interruption
# Unlike windows, ping -t always displays ping results on windows

[root@VM_0_3_centos ~]# ping www.baidu.com
PING www.a.shifen.com ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=54 time=3.97 ms
64 bytes from ( icmp_seq=2 ttl=54 time=4.01 ms
64 bytes from ( icmp_seq=3 ttl=54 time=3.97 ms
64 bytes from ( icmp_seq=4 ttl=54 time=4.03 ms
64 bytes from ( icmp_seq=5 ttl=54 time=3.97 ms
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 3.971/3.993/4.031/0.024 ms

As you can see from the first line of the result line, baidu's domain name is converted to www.a.shifen.com, sending 56 bytes of data.

Starting from the second line, the target returns information. The target receives 64 bytes, icmp_seq is the serial number of the received packet, ttl is the lifetime of the data packet, time is delayed, 3.97 milliseconds.

The last three lines are the statistical result information. Five packages were sent and five were received. One package was not lost. It took 4004 milliseconds. min/avg/max/mdev is the minimum/average/maximum/Mean Deviation delay.

ttl is time to life, that is, the lifetime of icmp packets on the network.

Examples of common ping commands:

ping -c 3 -i 3 -s 1024 -t 255 www.csdn.com
# - c: Fixed ping times, three times this time
# - i: Delivery interval, 3 seconds this time
# - s: Packet size, unit byte, 1024 is 1KB this time
# - t: 255, ttl value

[root@VM_0_3_centos ~]# ping -c 3 -i 3 -s 1024 -t 255 www.csdn.com
PING www.csdn.com ( 1024(1052) bytes of data.
1032 bytes from ( icmp_seq=1 ttl=250 time=38.4 ms
1032 bytes from ( icmp_seq=2 ttl=250 time=38.3 ms
1032 bytes from ( icmp_seq=3 ttl=250 time=38.4 ms

--- www.csdn.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6006ms
rtt min/avg/max/mdev = 38.334/38.402/38.447/0.167 ms

ping failure case:

ping -c 3 -i 3 -s 1024 -t 255 www.yaojiaxiaoyuan.com
PING www.yaojiaxiaoyuan.com.qiniudns.com ( 1024(1052) bytes of data.

--- www.yaojiaxiaoyuan.com.qiniudns.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 5999ms

As you can see, because my website www.yaojiaxiaoyuan.com is out of date for filing, all three packets sent during detection are lost, with a loss rate of 100%.

ping can only detect ip and domain names, but it can not detect ports. The next advanced command will say telnet, which can detect ports remotely.

2.6.4 cpu, process and memory monitor:

top command can be used to monitor the status of the cpu in real time and display the resource occupancy of each process in the system.

Common command examples:

# Yes, the parametric top command is the longest-used resource monitoring command.
# Next, I'll talk about some common interactive commands.

[root@VM_0_3_centos ~]# top
top - 23:03:23 up 127 days, 13:56,  2 users,  load average: 0.00, 0.01, 0.05
Tasks:  79 total,   1 running,  78 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.7 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3882032 total,   145996 free,   283752 used,  3452284 buff/cache
KiB Swap:  2097148 total,  1422392 free,   674756 used.  3218052 avail Mem 
PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                    
964 redis     20   0  142960   7244    988 S   0.3  0.2 168:01.87 redis-server                                                                                                               
15515 root      20   0  260068 123108   3988 S   0.3  3.2  20:12.97 YDService                                                                                                                  
30378 root      20   0  155536   2132   1540 R   0.3  0.1   0:00.06 top     
# There are a lot of things left behind, which are omitted.

Because the domain name has been cancelled, there is no screenshot at present, so we can only copy the text out.

The first line of the result is the execution result of the uptime command. Later, the advanced command will say that you can execute it if you are interested.

23:03:23  # Current system time    
up 127 days, 13:56 # The system has been running for 127 days, 13 hours and 56 minutes.

2 users # Two users are logged in
load average: 0.00, 0.01, 0.05 # Load status in the last minute, 5 minutes and 15 minutes

The second line is process information. A total of 79 processes, one running, 78 sleep, 0 stop, 0 dead.

The third line is the cpu status information.

0.2 us # Percentage of user space
0.0 sy # Kernel space ratio
0.0 ni # Changed priority process occupancy ratio
99.7 id # Percentage of idle CPU
0.2 wa # Percentage of cpu occupied by I/O wait
0.0 hi # Percentage of cpu occupied by hard interrupts
0.0 si # Percentage of cpu occupied by soft interrupts
0.0 st # Virtual Machine Occupancy Ratio

The fourth and fifth lines are physical memory state and virtual memory state respectively.

total # Total memory
free  # idle memory
used  # Used memory
buff/cache # cache

The sixth line is empty, and after the seventh line is the monitoring status of each process in the system.

PID  # Process id
USER # User, process owner
PR   # priority
NI   # nice value, negative value, high priority
VIRT # Total virtual memory used by processes, KB
RES  # The size of physical memory used, KB
SHR  # Shared memory size
S    # Process status. S = sleep, R = running, D = non-terminal dormant state, T=stopped, Z=zombie botnet process
%CPU # Percentage of CPU occupancy
%MEM # Percentage of physical memory occupied
TIME+ # CPU time statistics for processes
COMMAND # Process name

Examples of other commonly used commands:

top -c
# After the seventh line, the process information shows the whole path of the process.

top -n 2
# - n: The specified number of updates is not refreshed twice, and no parameters are refreshed all the time.

top interaction mode:

Press 1 to display multi-core CPU information.

A column can be highlighted by b, and the symbols "<" or ">" are used to sort it in descending order to the left or right.

There are many useful tools for resource monitoring, such as iostat, mpstat, iftop, vmstat, iotop, sar and so on. If you are interested, you can study them by yourself or wait for the next advanced linux command to come out.

III. Concluding remarks

This article has been written off and on for more than a month, and is finally finished today. The next one is linux Core Command Advancement and shell introduction.

Originally, the introduction to shell has been put into this article in the outline, but think about it, let's put it in the next article. That's it. There are so many linux commands, but most of the commonly used ones are included in this article.

Maybe there are some common commands related to file upload, download, installation, such as curl, wget, yum, rpm, ssh, scp, and so on, as well as system management, network management and so on.

Finally, I thank my wife for giving me so much power. Thank.

Sprinkle flowers, end, exit.

Public numbers are registered late and have no comment function, so they are usually used to send long text.
Knowledge planet is equivalent to the circle of technological friends. If you have questions, you can ask and discuss them.

Welcome to my public number: Yao Maomao's blog

Welcome to my knowledge planet. It's free at present.
Knowledge Planet: Yao Maomao's Private Garden

Keywords: Linux sudo shell Windows

Added by barneybarney68 on Tue, 08 Oct 2019 21:36:47 +0300