Linux commands are used to manage the Linux system. For Linux system, whether CPU, memory, disk drive, keyboard, mouse, or user are all files, Linux system management commands are the core of its normal operation, similar to DOS commands before. There are two types of Linux commands: built-in Shell commands and Linux commands.

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 find all of the XML file. Find -name" *. XML "| xargs grep" hello world "recursive search for all the file content contained in the XML file grep - H hello world 'spring' *. XML search so some XML files with spring find. / - size 0 | xargs rm -f & amp; Deleting the file size is zero ls -l | grep 'jar' search all the jar files in the current directory grep 'test' d * shows all begin with d file contains the test line. 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.Copy the code

2. Check whether a program is running

Ps - ef | grep tomcat to see all process about tomcat

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 To copy files cp -r sourceFolder targetFolder To copy entire folders recursively SCP sourecFile romoteUserName@remoteIp:remoteAddr Remote copyCopy the code

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 directoryCopy the code

9. Move files

mv /temp/movefile /targetFolder

10. Heavy orders

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 /test_one /test_two

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 will automatically display the new content, screen 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 view Java process ps aux view all processesCopy the code

23. List the contents of the directory as a tree

tree a

24. File download

wget http://file.tgz
curl http://file.tgz
Copy the code

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

30. Linux command learning website:

explainshell.com/

References:

Powerful and common commands in Linux include find and grep

Linux Command Summary _Common Linux command Line Examples _Linux Command Learning Guide

Linux commune – Linux common commands