Java development must be the Linux command

  • 2020-04-01 04:30:13
  • OfStack

This article will not explain all commands in detail, only common usage and explanation, specific usage can be used --help to view help.
1. Find files


find / -name filename.txt  Look up by name / In the directory filename.txt File. 

find . -name "*.xml"  Find all of them recursively xml file 

find . -name "*.xml" |xargs grep "hello world"  Recursively finds all files contained in the contents hello world the xml file 

grep -H 'spring' *.xml  Find all of them spring the xml file 

find ./ -size 0 | xargs rm -f &  Delete files with a file size of zero 

ls -l | grep 'jar'  Find all in the current directory jar file 

grep 'test' d*  Display all d Included in the opening file test The line. 

grep 'test' aa bb cc  Displayed in the aa . bb . cc Match in file test The line. 

grep '[a-z]{5}' aa  Displays all containing at least one of each string 5 The line of a string of consecutive lowercase characters. 

2. Check to see if a program is running


ps  � ef|grep tomcat  See all about tomcat The process of 

3. Terminate the thread


kill -9 19979  Terminates the thread bit 19979 The thread 

4. View files, including hidden files


ls -al

5. Current working directory The PWD

6. Copy files


cp sourceFolder targetFolder

scp sourecFile romoteUserName@remoteIp:remoteAddr  The remote copy 

7. Create a directory The mkdir newfolder

8. Delete the directory


rmdir deleteEmptyFolder  Delete empty directory  

rm -rf deleteFile  Recursively deletes everything in the directory 

Move files


mv /temp/movefile /targetFolder

10. Heavy order  


mv oldNameFile newNameFile

Switch users  


su -username

12. Modify file permissions  


chmod 777 file.java //File.java permissions - RWXRWXRWX, r for read, w for write, and x for executable

Compress files


tar -czf test.tar.gz /test1 /test2

14. Make a list of compressed files


tar -tzf test.tar.gz

15. Unzip the file


tar -xvzf test.tar.gz

16. View the first 10 lines of the file


head -n 10 example.txt

17. View the last 10 lines of the file


tail -n 10 example.txt

18. View log type files


tail -f exmaple.log //This command automatically displays the new content, and the screen displays only 10 lines of content (configurable).

Execute commands using super administrator identity


sudo rm a.txt  Delete files using administrator identity 

20. Check port usage


netstat -tln | grep 8080  Check the port 8080 Usage situation 

  The above 20 commands hope you master, hope to help you with Java development


Related articles: