This article was adapted from: Lebyte
This article mainly explains: Linux command
For more Java related knowledge, you can follow the public account “LeByte” to send: 999
This article does not cover all commands in detail, but only common usages and explanations. You can use –help to see help or just Google it.
1. Search for files
TXT Searches for the filename. TXT file in the/directory by name.
Find.-name “*.xml” recursively finds all XML files
. Find -name “*. XML” | xargs grep “hello world” recursive search for all the file content contained in the hello world of XML file
Grep -h ‘spring’ *.xml to find all XML files that contain spring
The find. / – size 0 | xargs rm -f & delete the file size is zero
The ls -l | grep ‘jar’ search all the jar files in the current directory
Grep ‘test’ d* Displays lines containing test in all files starting with d.
Grep ‘test’ aa bb cc Displays the line matching test in the aa, bb, cc file.
Grep ‘[a-z]\{5\}’ aa displays all lines containing strings with at least five consecutive lowercase characters per string.
2. Check whether a program is running
Ps – ef | grep tomcat to see all process about tomcat
Ps – ef | grep — color Java highlight to query keyword
3. Terminate the thread
Kill -9 19979 Terminates the process whose thread id is 19979
4. View files, including hidden files
ls -al
5. Current working directory
pwd
6. Copy files
Cp source dest Copies files
Cp -r sourceFolder targetFolder Recursively copies the entire folder
SCP sourecFile romoteUserName@remoteIp:remoteAddr Remote copy
7. Create a directory
mkdir newfolder
8. Delete the directory
Rmdir deleteEmptyFolder Delete an empty directory rm -rf deleteFile Recursively delete all contents in a directory
9. Move files
mv /temp/movefile /targetFolder
10. Renamed
mv oldNameFile newNameFile
11. Switch users
su -username
12. Modify file permissions
Chmod 777 file. Java // Permissions of file. Java – RWXRWXRWX, r indicates read, w indicates write, and x indicates executable
13. Compress files
tar -czf test.tar.gz /test1 /test2
14. List compressed files
tar -tzf test.tar.gz
15. Decompress the files
tar -xvzf test.tar.gz
16. Look at the first 10 lines of the file
head -n 10 example.txt
17. Look at the last 10 lines of the file
tail -n 10 example.txt
18. View the log type file
Tail -f exmaple.log // This command automatically displays the new content, and the screen displays only 10 lines of content (configurable).
19. Run commands as the super administrator
Sudo rm a. TXT Deletes files as an administrator
20. Check the port usage
Netstat TLN | grep 8080 view port 8080
21. Check which program the port belongs to
lsof -i :8080
22. Check the process
Ps aux | grep Java to check the Java process
Ps aux Views all processes
23. List the contents of the directory as a tree
tree a
Ps: Run the tree command in Mac
24. File download
Wget http://file.tgz Install the wget command on the MAC
curl http://file.tgz
25. Network detection
ping www.just-ping.com
26. Remote login
ssh userName@ip
27. Print information
Echo $JAVA_HOME Prints the value of the Java Home environment variable
28. Common Java commands
java javac jps ,jstat ,jmap, jstack
29. Other commands
svn git maven
28. Linux command learning website:
explainshell.com/
Thank you for your recognition and support, xiaobian will continue to forward “LeByte” quality articles