1. Document processing
1.1. Find files
find
grep
Find /data: find all files in /data (recursive)
Find/data-name index.html: finds the file named index.html in the /data directory
Find /data/conf-name index. HTML: Search multiple directories separated by Spaces
The find/data – the name ‘*. HTML’ | xargs grep “hello world” : find/data directory including hello world of HTML files.
Xargs: Perform subsequent operations after obtaining the filtering file
Grep -h ‘hello’ *. HTML: Find the HTML file containing hello in the current directory
Grep -l pattern *.html: List all file names that match the parttern
Grep -l pattern *.html: List all file names that do not match the parttern.
1.2. Working Catalog
pwd
ls
tree
PWD: Displays the absolute path of the current directory
Ls-al: View details of all files in the current directory (including hidden files)
Ls -l | grep ‘HTML’ : all the HTML file to view the current directory
Tree /data: displays all files in the /data directory in a tree structure
1.3. Document processing
touch
Create a filemkdir
Create a directorymv
: Moves a file or changes the file namecp
: Copy filesrm
: Delete fileschmod
: Modifies file permissions
TXT: creates the test. TXT file
Mkdir test: create the test directory
TXT: Changes the name of the test. TXT file to t.txt
TXT: Copy the t.txt file to t2.txt
Mv t.txt test: Move t.txt to the test directory
Rm t2. TXT, rm -r TXT
Chmod 777 T2.txt: Permissions required for modifying file operations read4(r),write2(w),exec1(x), left to right: [owner permission] [group permission] [others permission]
1.4. View files
head
tail
cat
more
grep
Head-n 10 common-default.log: displays the first 10 lines of a log
Tail -n 10 common-default.log: View the last 10 lines of a log
Tail-10f common-default.log: view the last 10 lines of a log and scroll to load the latest log
Cat -b common-default.log: displays all the contents of a file. The -b parameter is used to display the line number. The tac command is used to output the contents in reverse order
More common-default.log: displays files in pages. Use -10c to set the number of lines on a page, space to scroll down, and b to scroll up
Grep -n-20a ‘hello’ common-default.log: find the line number with hello content (-n),-20a display the context content of the target content (20 lines)
2. System processing
2.1. View processes
Ps – ef | grep Java: check the Java process (in accordance with ps – aux)
Ps – ef | grep — color Java: highlighting the Java process
Ps – axjf | grep nginx: tree shows nginx process
2.2. Check port usage
lsof
nestat
Lsof -i :8080: checks the usage of port 8000 on the server
Netstat TLN | grep 8080: check that the port 8080
2.3. View system resources
top
: Displays the usage of system resources
2.4. Remote operation
ssh
scp
SSH account@remoteIP: account account of the remote login server. RemoteIp Ip address of the server
SCP index.html account@remoteIP:remotePath: indicates the directory address of the remote server where files are copied to
2.5. Kill the process
kill -9 6239
: Forced killing6239
process
2.6. Switch users
su admin
: switch to theadmin
account