VI Editor _ Terminal Editor (Key key key)

The target

  1. Vi introduction
  2. Open and create new files
  3. Three working modes
  4. Common Command Query

1 introduction

1.1 Purpose of learning VI

  • To make simple changes to files on the server, you can log in to the remote server using SSH and use the VI editor to make simple changes

  • The following files need to be modified

    • The source code
    • The configuration file
      • For example, the Tomcat server configuration file

      • For example, the configuration file of the nic information

    For editing files without a graphical interface, VI is the best choice. Every programmer using Linux should learn some of vi’s common commands

1.2 vi and vim

1.2.1 VI

  • Vi isvisual interfaceIs short for LinuxThe most classicText editor
  • The viCore design idea
    • By keeping the programmer’s fingers in the core of the keyboard, all editing can be done
  • The characteristics of the vi
    • Edit text only, not text paragraphs
    • Mouse operation is not supported
    • No menu
    • Only the command
  • The vi editor will never be as powerful as the graphical editor when it comes to managing and editing files in the system administration server

1.2.2 VIM

ViM is a text editor developed from VI, which supports code completion, compilation, error jump and other convenient programming functions. It is widely used among programmers and is known as the god of editors

2 Open and create a file

  • Enter vim in the terminal followed by the file name
Vim filenameCopy the code
  • If the file already exists, it will be opened directly
  • If the file does not exist, a new file is created when you save and exit
1 File name that ViM does not have 2 Edit content 2.1 Output a Statement 2.2 Copy and Paste 2.1 Content 19 times 2.3 Save and Exit 3 ViewCopy the code

Note: This section focuses on opening and creating files. The other commands will be explained later

2.1 Open the file and locate the line

  • In your daily work, you might encounter situations where you open a file and locate it to a specified line
  • For example, during development, if you know that a certain line of code has an error, you can quickly locate the error code
  • At this point, you can use the following command to open the file
Vim file name + line numberCopy the code

Tip: If you add + without specifying a line number, you will go directly to the end of the file

2.2 Three working modes of VI

  • VI has three working modes
  1. Command mode
    • To open the file, first enter the command mode, which is the entrance to use VI
    • Use commands to perform general editing operations on files, such as locating pages, copying, pasting, deleting… .
    • In other graphics editors, actions performed by shortcut keys or mouse are performed in command mode
  2. Last line mode — ExecuteSave the exitOperations such as
    • To exit VI and return to the console, you need to enter a command in mow mode
    • The last-line mode is the exit of VI
  3. Edit mode – Normal text editing

2.4 Last-line Mode Commands

The command English function
w write save
q quit Exit, if not saved, not allowed to exit
q! quit Forced exit, exit without saving
wq write & quit Save and exit (Morow mode)
x Save and exit (Morow mode)
ZZ Save and exit (command mode)

3 Common Commands

Study tips

  1. Vi command more, do not expect to remember all at once, individual command forget, just will affect the editing speed. When using the vi command, disable the Chinese input method

3.1 mobile

To use vi proficiently, you should first learn how to quickly move the cursor in command mode

1) Up, down, left, right

The command function finger
h To the left The index finger
j down The index finger
k upward The middle finger
l To the right The ring finger

2) Inline movement

The command English function
w word Move one word back
b back Move one word forward
0 The beginning of a line
^ At the beginning of the line, the first position is not whitespace
$ End of each line

3) Row number movement

The command English function
gg go At the top of the file
G go The end of the file
Digital gg go Move to the number corresponding to the number of lines
Digital G go Move to the number corresponding to the number of lines
: digital Moves to the number of rows corresponding to the number

4) Screen movement

The command English function
Ctrl + b back Page up
Ctrl + f forward Down the page
H Head The top of the screen
M Middle In the middle of the screen
L Low At the bottom of the screen

3.2 Mobile (Program)

1) Paragraph movement

  • Vim uses blank lines to distinguish paragraphs

  • When you’re developing a program, it’s common to write a piece of feature-related code next to each other — with no blank lines between them

    The command function
    { On a
    } The next leg of

2) Switch parentheses

  • In the program world, **(), [], {}** are highly used, and they all come in pairs.

    The command function
    % Parenthesis matching and switching

3.3 Selecting Text (Visual Mode)

  • Before learning the copy command, you should learn how to select the code to copy
  • To select text in VI, display the Visual command to switch to visual mode
  • Vi provides three visual modes that make it easy for programmers to choose how text is selected
  • Press ESC to deselect and return to command mode
The command model function
v Visual model Select text in normal mode starting at cursor position
V Visual mode Select the full row over which the cursor passes
Ctrl + v Visual block mode Select text vertically
  • In visual mode, it can be used with move commands, such as ggVG to select all contents

3.4 Revoke and Resume Revoke (Life order)

Before learning the edit command, you should know how to undo a previous wrong edit operation

The command English function
u undo Undo last command (CTRL + Z)
Ctrl + r uredo Undo undo command

3.5 Deleting Text

The command English function
x cut Deletes the character where the cursor is located or the selected text
D (Move command) delete Delete the contents of the move command
dd delete Delete the cursor line, you can NDD delete multiple lines
D delete Delete to end of line

Tip: If a text is already selected in visual mode, you can remove the selected text with either D or X

The delete command can be used with the move command. The following are common combination commands:

The command role
dw Delete from cursor position to end of word
d0 Deletes from cursor position to the start of a line
d} Delete from cursor position to end of paragraph
ndd Deletes n consecutive rows from cursor position down

3.6 Copy and Cut

  • Vi provides a buffer for copied text
    • The copy command saves the selected text in a buffer
    • The text deleted by the delete command is saved in the buffer
    • Use the paste command to insert the buffered pair of text at the desired location
The command English function
Y (copy command) copy copy
yy copy Copy one row, you can nyY copy multiple rows
D (cut command) delete shear
Dd (shear) delete Cut one row, you can NDD cut n rows
p paste paste

Tip:

  • Commands D and x are similar to graphical clipping operations — CTRL + X
  • The y command is similar to the graphical copy operation — Ctrl + C
  • The command p is similar to the graphical interface paste operation — Ctrl + V
  • The text buffer in VI has only one text buffer. If the text buffer is copied or cut later, the content in the buffer will be replaced.

Pay attention to

  • The text buffer in VI is not the same as the system clipboard
  • So use it in other softwareCtrl + CCopy content that can no longer beviThrough thepPaste command
  • You can use the right mouse button to paste in edit mode

3.7 replace

The command English function Working mode
r replace Replace current character Command mode
R replace Replaces the character after the current line cursor Replace mode
  • RCommand can enterReplace modeAfter the replacement is complete, pressESC, press theESCYou can return toCommand mode
  • The purpose of the replace command is to make lightweight changes to the file without going into edit mode

3.8 find

Conventional search

The command function
/str Find the STR
  • After finding the specified content, use Next to find the Next location to appear

    • n: Find the next one
    • N: Find the previous one
  • If you don’t want to see the highlight, you can just look for anything in a file that doesn’t exist

  • Quick word matching

The command function
* Find the word behind the current cursor
# Look forward to the word where the cursor is currently located
  • In development, word quick matching allows you to quickly see that the word has been used in other places

3.9 Search and Replace

  • inviFind and replace commands are required inAt the end of the line modeperform
  • Memory command format
:%s///g
Copy the code
  1. Global replacement
  • Replace all occurrences of old text in the file at once

  • The command format is as follows:

    :%s/ old text/new text /gCopy the code
  1. Visual area replacement
  • Select the range of text you want to replace
  • The command format is as follows:
:s/ old text/new text /gCopy the code
  1. Confirm to replace

C confirm confirm

  • If you change the end of g to GC, there will be a hint! It is recommended to use

  • The command format is as follows:

    :%s/ old text/new text/GCCopy the code
  1. yyesreplace
  2. nnoDon’t replace
  3. aallReplace all
  4. qquitExit the replacement
  5. llastLast, and move the cursor to the top of the line
  6. ^EScroll down
  7. ^YScrolling up

3.10 Inserting Commands (Major)

  • In vi except commonly usediEnter theEdit modeThe following command is also provided to enter the editing mode
The command English function The commonly used
i insert Inserts text before the current character The commonly used
I insert Insert text at the beginning of the line The commonly used
a append Adds text after the current character
A append Add text at the end of the line The commonly used
o Inserts an empty row after the current row The commonly used
O Inserts an empty row before the current row The commonly used

[imG-RQHJJGGN-1624685398655] (F:/%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2/%E4%BC%A0%E6% 999B A%E4%B8%93%E4%BF%AE%E5%AD%A6%E9%99%A2/1812/01linux/%E8%AE%B2%E4%B9%89/02_%E6%89%93%E5%8C%85%E5%8E%8B%E7%BC%A9_vim%E7%BC% 96%E8%BE%91%E5%99%A8_%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86_%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90/%E7%AC%94%E8%AE%B0/assets /1558543477231.png)]

3.11 practice

Exercise 1 – Edit commands and numbers together

  • During development, you might encounter N consecutive inputs of the same character
  • Such as:* * * * * * * * * *10 consecutive asterisks

This can be done in command mode

  1. The input10Is repeated 10 times
  2. The inputiEnter theEdit mode
  3. The input*That is, repeated words
  4. Press theESCreturnCommand mode, after returningviYou can put the first2, 3,The two-step operation repeats10

Tip: In normal development, do not press numbers until you enter edit mode

Search command

2. Find the search

The preparatory work
Switch the directory to /export/ and clear the contents

cd /export/ && rm -rf /export/* && tree

Add a directory and switch the directory and add a file

mkdir -p /export/aaa/bbb/ccc/ddd/eee/ touch /export/aaa/bbb/ccc/ddd/eee/abc.txt touch /export/aaa/123.txt touch /export/aaa/312.txt

View the contents of the /export directory

tree /export

The target

  • throughfindThe commandIn a specific directory (including its descendants)searcheligibleThe file

2.1 the path

  • Step 1: search for abc.txt files in the specified directory
  • Step 2: Search for the file name in the specified directory1The file
  • Step 3: search under the specified directory, all.txtIs a file with an extension
  • Step 4: Search the specified directory to the number1Opening file

2.2 Implementation: Search by name in the specified directory

  • The command format

The serial number The command format role
01 Find [path] -name ‘*.txt’ Find files with the.txt extension in the specified path, including subdirectories
  • If the path is omitted, the search is performed in the current folder
  • The wildcards you learned earlier are also available when using the find command
  • Step 1: search for abc.txt files in the specified directory

# = = = = = = = = = = = = = = = = = = = target = = = = = = = = = = = = = = = = = = = = = = = = = = = = way # 1: find the directory/export / -name 'ABC. TXT' way of # 2: Find. -name 'abc.txt' # find. -name 'abc.txt'Copy the code
  • Step 2: Search for the file name in the specified directory1The file

# = = = = = = = = = = = = = = = = = preparation = = = = = = = = = = = = = = = # 1 to create a test file touch/export / 12. TXT/export / 616. TXT/export / 321. TXT # = = = = = = = = = = = = = = = = = implement directory = = = = = = = = = = = = = = = the find/export / -name "* 1 *"Copy the code
  • Step 3: search under the specified directory, all.txtIs a file with an extension

find /export/ -name "*.txt"
Copy the code
  • Step 4: Search the specified directory to the number1Opening file

find /export -name "1*"
Copy the code

2.3 summary

  • throughfind [path] -name "*1*"The search for files by name is complete

Decompression command

  • The preparatory work
CD /export/ && rm -rf * # create test file touch 1.txt 2. TXT 3. TXT # create test directory mkdir -p /export/aaa/ touch /export/aaa/4.txt /export/aaa/5.txtCopy the code

The target

  • From a third partydownloadCompressed package,After the decompressionInstall it on the server
  • Compress backup files by packaging

Jar: Java Rar Compressed package of the Java project

War: Web Rar Compressed package of the Web project

The path

  • 2.1 Step 1: Pack and unpack

  • **2.2 Step 2: Pack and unpack **

3. The implementation

3.1 Step 1: Package and unpack

3.1.1 packaging

  • It’s like putting winter clothes in a bag

  • Large packaged files need to end in.tar.

Tar Format of the package command

#Package a series of files into one large filePackage name tar directory to be packaged tar file to be packaged 1 File to be packaged 2 File to be packaged 3 File to be packagedCopy the code

Tar option description

The command English meaning
c create Generate archive files and create package files
v Verbosely Report progress like Tang Seng
f file Specifies the file name of the file, which must follow f.tarFile, so it has to go back to the left
Exercise 1: Package 1. TXT, 2. TXT, and 3. TXT as 123.tar files Exercise 2: Package the AAA directory with content as aaaCopy the code

3.1.2 unpack

  • It’s like taking winter clothes out of a bag

Tar Format of the unpack command

#Decompose a packaged file into a series of small files in the current directoryTar -xvf Package name. Tar
#Decomposes a packed file into a series of small files in a specified directoryTar -xvf Package name tar -c Path for unpacking packagesCopy the code
The command English meaning
x Extract (extract) Unpack the
C (capital C) A directory Save to current directory by default, pass-CChange the decompression directory. Note: The decompression directory must exist
Exercise 1: Decompress 123.tar to the current directory Exercise 2: Decompress aaa.tar to /export/test/a1/b1/c1/Copy the code

summary

Package: tar -cvf Name of the package tar Directory or name of the package Decompressed: tar -xvf name of the package decompressed: tar -xvf name of the package decompressed: tar [-c specifies the decompression location]Copy the code
  • The preparatory work

    CD /export/ && rm -rf * # create test file touch 1.txt 2. TXT 3. TXT # create test directory mkdir -p /export/aaa/ touch /export/aaa/4.txt /export/aaa/5.txtCopy the code

3.2 Step 2: Compress and decompress in GZIP format

  • Packaging and compression are two things

  • It is similar to putting winter clothes into compression bags and then extracting air from them

  • In Linux, the most common compressed file format is XXX.tar. gz

  • The tar command has an option -z to call gzip, which makes it easy to compress and decompress

The command format is as follows:

Tar.gz Compressed file/directory Gz # Decompress the package to the specified directory: tar -zxvf package.tarCopy the code

Tar option description

The command English meaning
z gzip Use gzip compression and decompression
j bzip2 Use bzip2 compression and decompression
TXT, 2. TXT, and 3. TXT to a 123.tar.gz file in Gzip Format Exercise 1: Package the 1.txt, 2.txt, and 3. TXT file as a 123.tar.gz file in Gzip format Exercise 2: Package the AAA directory with contents as a AAa.tar. gz file in Gzip format Exercise 3: Unpack 123.tar.gz to the current directory (Gzip) Exercise 4: Unpack aaA.tar. gz to the /export/ BBB directory (gzip)Copy the code

summary

Gz Directory or file name to be compressed Decompress the package decompress: tar -zxvf File name to be compressed. Tar. gz [-c specify the decompress location]Copy the code
  • The preparatory work

    CD /export/ && rm -rf * # create test file touch 1.txt 2. TXT 3. TXT # create test directory mkdir -p /export/aaa/ touch /export/aaa/4.txt /export/aaa/5.txtCopy the code

3.3 Step 3: Compress and uncompress using bzip2 format

  • bzipIt’s the second way of compression
  • It is similar to putting winter clothes into compression bags and then extracting air from them
  • inLinuxThe bzip2 compressed file format isxxx.tar.bz2
  • intarThe command has an option called -jbzip2, so that you can easily realize the function of compression and decompression

The command format is as follows:

Bz2 Compressed file/directory # Decompress file (performance Weifang) tar -jxvf package file.tar. Bz2 # Decompress to the specified path tar -jxvf package file.tar Directory pathCopy the code

Tar option description

The command English meaning
z gzip Use gzip compression and decompression
j bzip2 Use bzip2 compression and decompression
Exercise 1: Package 1.txt, 2.txt, and 3. TXT as 123.tar.bz2 files (bzip2) Exercise 2: Package aaa directories with contents as aaa.tar.bz2 files (bzip2) Exercise 3: Package aaa directories as aaa.tar.bz2 files (bzip2) Unpack 123.tar.bz2 to the current directory (bzip2) Exercise 4: Unpack aaA.tar. bz2 to /export/ BBB (bzip2)Copy the code

summary

Package compression: tar -jcvf File name after packaging.tar.bz2 Directory or file name after package compression Decompress: tar -jxvf file name after package decompress: tar.bz2 [-c specify the decompression location]Copy the code

To turn it off

halt
Copy the code

restart

reboot
Copy the code

4 Commands related to user permission

The target

  • Understand the basic concepts of users and permissions
  • User management terminal commands
  • Group management terminal command
  • Modify permission terminal command

Basic concepts of users and permissions

4.1 Basic Concepts

  • User is an important part of Linux system. User management includes user and group management

  • In Linux, each system must have an account and has different permissions for different system resources, whether you log in to the system at the local level or remotely

  • Permissions for files/directories include:

The serial number permissions English abbreviations Digital serial number
01 read read r 4
02 write write w 2
03 perform execute x 1
04 Without permission 0
  • In Linux, you can specify different permissions for different files or directories for each user

4.2 group

  • In order to facilitate user management, proposedgroupAs shown in the figure below

4.3 LS-L Extension

[Img-LWckbqr0-1624685398660] (Assets %5CUsers%5CAdministrator%5CAppData%5CRoaming%5CTypo ra%5Ctypora-user-images%5C1570973470529.png)]

  • Ls -l You can view details about the files in the folder from left to right.

    • permissions, the first character if isdSaid directory
    • The number of hard links, colloquial, is the number of ways to access the current directory and file
    • Owner, the owner of the file/Magnolia in the home directory is usually the current user
    • Groups, in Linux, a lot of times, the group name and the user name are the same, we’ll talk about that later
    • The size of the
    • time
    • The name of the

4.4. Group Management terminal commands

Essence: Assign permissions to users of the same type

The serial number The command role
01 Groupadd group name Add the group
02 Groupdel group name Delete the group
03 cat /etc/group Confirm group Information
04 CHGRP Group name Name of a file or directory Example Modify the owning group of a file or directory

Tip:

  • The group information is saved in/etc/groupIn the file
  • /etcDirectories are designed for preservationSystem Configuration informationThe directory where the
  • In practice, you can set permissions for groups in advance and then add different users to the corresponding groups instead of setting permissions for each user in turn

Drills target

  1. In the specified directoryaaadirectory
  2. newdev
  3. willaaaThe directory group is changed todev

4.5. User Management Terminal commands

(1) Create a user/set a password/delete a user

The command role instructions
Useradd -m -g Group user name Adding a New User -mAutomatically create user home directories

-gSpecify the group to which the user belongs, otherwise a group with the same name will be created
Passwd username Setting a User Password For ordinary users,

Run the passwd command to change the password of your own account
Userdel -r Indicates the user name Delete user -rOption will automatically delete the user’s home directory
The cat/etc/passwd | grep user name Confirm user Information After a user is created, the user information is saved in the/etc/passwdfolder

Tip:

  • Create, if you forgot to add-mThe option specifies the new user’s home directory — the easiest way to do this isDelete the user and create it again
  • When a user is created, a group name is created by default
  • The user information is saved in the /etc/passwd file

The /etc/passwd file stores user information. The file consists of seven types of user information

  1. The user name
  2. Password (x, for encrypted password)
  3. UID (User identity)
  4. GID(Group flag)
  5. User’s full name or local account
  6. The home directory
  7. The Shell used for login is the terminal command used after login

(2) View user information

The serial number The command role
01 Id [User name] View the UID and GID of a user
02 who View the list of all users currently logged in
03 whoami View the account name of the current login user

(3)suSwitch the user

  • Because regular users cannot use certain permissions, you need to switch users
The serial number The command role instructions
01 su -The user name Switch users and plan directories -You can switch to the user’s home directory, otherwise leave the location unchanged
02 exit Exit the current user
  • suDo not use the username, you can switch toroot, but it is not recommended because it is not safe
  • exitThe schematic diagram is as follows:

(4)sudo

  • althoughthroughsu -u rootI can go toThe root user.butIn the presence of severeSafe hidden trouble
  • In Linux, the root account is used for system maintenance and management and has the permission to access all resources in the operating system

  • If you use rm-RF carelessly… . “Could bring down the system

  • On most versions of Linux, it is not recommended to log in to the system as user root

  • Using the sudo command, you can execute commands with another identity. The default identity is root

  • To use sudo, a user must enter a password for a period of five minutes before reentering the password

    Tip: If its unauthorized users attempt to use Sudo, a warning message will be sent to the administrator

(4.1) Grant permissions to specified users

  • Essence: Notifies the server to assign temporary administrator rights to a specific user

vim /etc/sudoers

=(ALL) ALL=(ALL) ALL=(ALL) ALL=(ALL) ALL=(ALL) ALLCopy the code

(4.2) UserszhangsanLog in and operate administrator commands

  • Essence: Use temporary administrator privileges
Sudo useradd -m -g dev zhaoliuCopy the code

Preparations: Perform operations as user root

Rm -rf /export/* # create test directory mkdir -p /export/aaa/ touch /export/aaa/01.txt /export/aaa/02.txt # View the contents of the specified directory tree /exportCopy the code

(5). Modify user permissions

The serial number The command role
01 chmod Modify the permissions

5.1 Method 1: Changing User Rights

  • Chmod allows you to modify the permissions of users or user groups on files or directories

  • The command format is as follows:

    Chmod + / - RWX filename | directory nameCopy the code

    Note: The previous mode changes the owner/group permissions at a time

Target drill:

Mysql > delete directory from user root with read/write/execute permission Cannot switch to this directory # 3 using other users such as Zhangsan. Add the execute permission to the directory using root. Switch to the directory using Zhangsan againCopy the code

5.2 way 2

  • Though way directly modify the file read write | | | the directory execute permissions, but not accurate to the owner group | | the other permissions
  • The command format is as followsuIndicates the owning user /gIndicates the owning group /oOther)
Chmod -r u = RWX, g = rx, o = RWX file | directoryCopy the code
The serial number permissions English abbreviations Digital serial number
01 read read r 4
02 write write w 2
03 perform execute x 1
04 Without permission 0

Target drill:

# 1 Assign read, write, and execute permissions to owning users, to owning groups, and to other users as user rootCopy the code

5.3 Mode 3: Simplify Mode 2

  • The command format is as follows:
Chmod -r 755 | catalog fileCopy the code
  • The first number indicates the owner rights, the second number indicates the group rights, and the third number indicates the rights of other users

Common numeric combinations include u for user/G for group/O for others.

  • 777= = = >u=rwx, g=rwx, o=rwx
  • 755= = = >u=rwx, g=rx, o=rx
  • 644= = = >u=rw, g=r, o=r

Target drill:

# 1 Assign read, write, and execute permissions to owning users, to owning groups, and to other users as user rootCopy the code

Commands related to system information

  • This section describes how to view the current system date and time, disk space usage, and program execution on the server when you maintain the server on a remote terminal
  • All terminal commands are query commands. You can learn about the usage of system resources by using these commands

The target

  • Time and date
    • date
    • cal
  • Disk and directory space
    • df
    • du
  • Process information
    • ps
    • top
    • kill

1. Time and date

1.1 the date time

The command role
date Viewing system time (The default)
date +”%Y-%m-%d %H:%M:%S” Viewing system time (The specified format)
Date -s “Time string” Setting the System Time

Step 1: Display the current time

# # show time date according to the specified formats display date + time "% % Y - m - H: % d % % m: % S"Copy the code

Step 2: Set the system time

Date -s "Time string"Copy the code

1.2 CAL calendar

The serial number The command role
01 cal View the calendar for the current month
02 cal -y View the calendar for the current year
03 cal 2020 Check out the calendar for 2020
04 cal 10 2020 Check out the calendar for October 2020

02. Disk information

The serial number The command role
01 df -h Disk Free Displays the free disk space
02 Du -h [directory name] Disk Usage Displays the directory size under the directory
  • Option to show
parameter meaning
-h Display file size in a user-friendly way

03. Process information

  • A process, colloquially, is a process that is currently executing
The serial number The command role
01 ps aux Process Status Displays process details
02 top Dynamically displays running processes and sorts them
03 Kill [-9] Indicates the process id Terminating a process with a specified code. -9 forcibly terminates the process

By default, ps displays only the applications started by the current user on the terminal

  • Ps Option Description Function

    options meaning
    a Displays all processes on the terminal, including those of other users
    u Displays the detailed status of processes
    x Displays processes that do not control terminals

    Tip: When using the kill command, you are advised to stop only the processes started by the current user rather than the processes started by the root user. Otherwise, the system may crash

  • To exit top, type Q

top

Us Percentage of CPU used by user space SY Percentage of CPU used by kernel space NI Percentage of CPU used by user processes whose priorities changed ID Percentage of idle CPU WA Percentage of CPU time waiting for input and output Hi Hardware interrupt SI Software interrupt ST: real-timeCopy the code

PID Process ID USER USER name PR Priority NI Nice value. A negative value indicates the high priority, and a positive value indicates the low priority. M RES Indicates the size of physical memory used by the process but not swapped out. The unit is KB SHR shared memory size. D= Uninterruptible sleep R= Running S= Sleep T= Tracing/Stopping Z= Zombie process %CPU CPU Usage %MEM Percentage of physical memory used by a process TIME+ Total CPU TIME used by a process, expressed in 1/100 second COMMAND Indicates the COMMAND executed