Common commands for linux development

1. Find the file

find / -name filename.txt Find the filename.txt file under the / directory by name.

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

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

grep -H  'spring' *.xml Find all the xml files that contain spring

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

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

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

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

grep '[a-z]\{5\}' aa Displays all lines containing strings with at least 5 consecutive lowercase characters per string.

2. See if a program is running

ps –ef|grep Java View all processes related to java

3. Terminate the thread

kill -9 12345 Terminate the thread with thread number 19979

4. View files, including hidden files

ls -al

5. Current working directory

pwd

6. Copy files

cp  source dest copy file

cp -r  sourceFolder targetFolder Copy entire folder recursively

scp sourecFile romoteUserName@remoteIp:remoteAddr remote copy

7. Create a directory

mkdir newfolder

8. Delete the directory

rmdir deleteEmptyFolder delete empty directory  rm -rf deleteFile recursively delete all contents in a directory

9. Move files

mv /temp/movefile /targetFolder

10. Heavy order

mv oldNameFile newNameFile

11. Switch users

su -username

12. Modify file permissions

chmod 777 file.java //Permission of file.java - rwxrwxrwx, r means read, w means write, x means executable

13. Compressed 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 will automatically display the new content, and the screen only displays 10 lines of content (can be set).

19. Execute commands as super administrator

sudo rm a.txt Delete files as administrator

20. View port occupancy

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

21. See which program the port belongs to

lsof -i :8080

22. View the process

ps aux|grep java View java process

ps aux View all processes

23. List the contents of the directory as a tree diagram

tree a

 

25. Network Detection

ping www.taobao.com

26. Remote login

ssh userName@ip

27. Printing Information

echo $JAVA_HOME Print the value of the Java  home environment variable

28.java common commands

java javac jps ,jstat ,jmapjstack

转载:http://blog.csdn.net/clz1314521/article/details/51756179

Guess you like

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