Commonly used Linux commands for JAVA development

1. Find the file find / -name filename.txt Find the filename.txt file in the / directory according to the name.

find . -name "*.xml" recursively finds all xml files

find . -name "*.xml" |xargs grep "hello world" Recursively find xml files containing hello world in all file content

grep -H 'spring' *.xml  finds some xml files that contain spring

find ./ -size 0 | xargs rm -f & delete files with file size zero

ls -l | grep '.jar' finds all jar files in the current directory

grep 'test' d* displays all lines that contain test in files starting with d.

grep 'test' aa bb cc shows lines matching test in aa, bb, cc files.

grep '[az]\{5\}' aa displays all lines containing strings with at least 5 consecutive lowercase characters per string.

2. Check if a program is running ps –ef|grep tomcat to see all the processes related to tomcat

3. Terminate the thread kill -9 19979 Terminate the process with thread number 19979

4. View files, including hidden files ls -al

5. The current working directory pwd

6. Copy files  cp source dest  copy files cp -r sourceFolder targetFolder recursively copy the entire folder scp sourecFile romoteUserName@remoteIp:remoteAddr remote copy

7. Create a directory  mkdir newfolder

8. Delete the directory  rmdir  deleteEmptyFolder delete the empty directory rm -rf deleteFile recursively delete all contents in the directory

9. Move the file mv /temp/movefile /targetFolder

10. Re-command mv oldNameFile newNameFile

11. Switch user su -username

12. Modify the file permissions chmod 777 file.java //file.java permissions -rwxrwxrwx, r means read, w means write, x means executable

13. Compress the file tar -czf test.tar.gz /test1 /test2

14. List the compressed file list 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 10 lines at the end 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, and the screen only displays 10 lines of content (can be set).

19. Execute the command sudo rm a.txt as a super administrator to delete the file as an administrator

20. Check the port usage netstat -tln | grep 8080 Check the usage of port 8080

21. Check which program the port belongs to lsof -i :8080

22. View process ps aux|grep java View java process ps aux View all processes

23. List the contents of the directory in a tree diagram tree a ps: use the tree command under Mac

24. File download wget http://file.tgz Install wget command curl http://file.tgz under mac

25. Network detection ping www.just-ping.com

26. Remote login ssh userName @ip

27. Print information echo $JAVA_HOME to print the value of the java home environment variable

28.java common commands java javac jps , jstat , jmap, jstack

29. Other commands svn git maven

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325197101&siteId=291194637
Recommended