Common shell command buttons + function description

Common shell command buttons + function description

a. File commands:
1.who: which machines are connected to linux
2.pwd: display the current file location
3.ls /: parameter / means the root directory, which means to display the files under the root directory
4.ls: The command is a file list command, which displays the list of files and directories in the specified directory
5.cd /parameter: go to the directory where the parameter is located 6.parameter
/$ cd: return to the home directory (home)
7.cd.: The current directory
8.cd …: The upper level directory -> Appears::/Upper level directory $
9.cd…/…: Return to the upper level of the previous level, each level returned does not add a /... (essentially the same as the cd / parameter (Equivalent)
10.: Just write cd to return to the main directory
11.ls: What files are in the current directory
12.ls -l: Details of each file in the current directory (permission, date...) ls-l aaa. txt abc.txt……means that only the details of aaa,abc…
14. Permission: please refer to the word document for details
Insert picture description here

1 represents the number of hard links similar to the pointer
. The first letter represents the type of file: "d" represents a folder, "-" represents an ordinary file, "c" represents a hardware character device, "b" represents a hardware block device, and "s" Represents a pipeline file, and "l" represents a soft link file.
The last 9 letters represent three sets of permissions: file owner, user, and permissions owned by other users.
15.touch: New->touch file name. File type
16.ls a*: only list the files in this directory starting with a, aa means starting with aa
17.ls *.dat: only list dat files

18.ls b?c.txt: you can find files that only contain b c.txt
19.cp: copy files -> cp aaa.txt aaa.bak cp -i: -i means to ask first and
pay attention to cp- l aaa.txt abc.txt means reference, that is, the addresses (inode) of aaa and abc are the same.
If -l is not written, their inodes are different
. It is applicable to copying into the same type of file and different types of files . 20. vim modify the file ->vim aaa.txt shift+A,ESC,:wq!
21.ls -sail A string of numbers at the beginning: inode refers to where the hard disk is stored
22.stat file name can view more detailed information about the file
23.rm: delete files -> rm file name
24 mkdir: create directory -> mkdir create directory name
25.rmdir: delete directory -> rmdir the name of the directory to be deleted
26.rm -r doc force delete the directory with files under the directory
27 file aaa.txt: See what type of file content is
28. The hard link must be under the same inode. The soft link points a file to another file. When searching for the file, you will always find the one pointed to,
such as the hard link cp -l soft Connect cp -s once the final file is deleted, then all connected soft files will be invalid
29.ln create hard link ln -s create soft link
30.cat: view file content cat file more, less is also view file, but large file More can hide the part that exceeds the screen, and
press Enter to view 31.mv: change the file name mv, the old name and the new name
32.~: Indicates the main directory
33.mkdir -pa/b/c……Create all subdirectories at one time
34.tail: tail file name only view the last 10 lines of this file, tail -nx file name view the last x line tail- f -nx file name real-time view file content
35.head and tail are the same, but clear the screen from the beginning
b. System command
1.ps: view process (under current user (lack of root), how many programs are being executed) ps PID view a certain process
2.ps -ef: display all processes, -f display complete output
PID: program serial number PPID: the father of the process (that is, who derived the process from) TTY: running terminal TIME: cumulative use of CPU Time CMD: shell command name
C: cpu utilization STIME: startup time
3. Another style code ps al
VSZ memory occupied by RSZ physical memory occupied (KB) STAT status S sleep R running S< process priority SN process Low priority Ss console process S+: running on the front end
4.top: real-time display process
Display: how long the system has been running at the current time Average load of several users: the last 1min 5min 15min
tasks: the total number of
CPUs running sleeping and stopped Usage
Memory usage: buffer (buffer)
hard disk swap space
PR: process level (the higher the priority) NI: the degree of humility (the lower the higher) VIRT: virtual memory
RES: physical memory SHR: process and other processes shared Memory S: State CPU: Percentage of CPU occupied
MEM: Percentage of memory usage TIME+: Time spent consuming CPU
q Exit top
5.htop: The interface is more beautiful
6. kill/kill -s INT: End process: kill/kill -s INT PID
7. kill -9: Forced end
8. The killall command is used to terminate all processes corresponding to a service with a specified name, in the format: "killall [parameter] [service
name]"
9.df/df -h: view disk space
10.du: view current directory
11 .grep: grep keyword file name -> you can view all lines containing keywords in the
file grep -c keyword file name -> output a few lines containing keywords (numbers)
grep -v keyword file name -> output no The line containing the keyword (the entire line)
grep -n keyword file name -> You can view all the lines containing the keyword in the file, and output the line number.
For example, if the keyword is apple, you can enter ap*le to find all lines that contain this The four-letter word
ps | grep CMD only displays the CMD process (| means the output of ps is the input of grep)
12.zip/unzip: pack/unpack
14. wget -c website: download files from the website, -c means break Click to continue.
15. echo $PATH (variable): view environment variables
16. printtenv: view global variables
17. printenv | grep command: view the file where the command is located
18. Set environment variables:
Example: Set the environment variable
test=goodcpp with the variable name test.
Echo $test
will output good cpp at this time,
but as long as you enter a new SHELL, test will become invalid (local variables only take effect in the subshell) echo $test will not output
if Need to save the input for a long time: export test (variable name) is
enough. When you need to restore, enter unset test (variable name)
19. vim ~/.bashrc view shell
20. chmode +x file name to add permissions to the file r/w/x

Guess you like

Origin blog.csdn.net/weixin_44067773/article/details/108677293