Beijing Shang Academy offers
This article does not explain all the commands in detail, only the common usage and explanations. You can use --help
view Help or learn directly from Google search.
1. Find Files
find / -name filename.txt
Find the Filename.txt file under the name/directory.
find . -name "*.xml"
Recursive lookup of all XML files
find . -name "*.xml" |xargs grep "hello world"
Recursively find XML files with Hello World in all file contents
grep -H ‘spring‘ *.xml
Find so some XML file that contains spring
find ./ -size 0 | xargs rm -f &
Delete files with a file size of zero
ls -l | grep ‘jar‘
Find all jar files in the current directory
grep ‘test‘ d*
Displays all rows that contain test in a file that begins with D.
grep ‘test‘ aa bb cc
Displays the line that matches test in the aa,bb,cc file.
grep ‘[a-z]\{5\}‘ aa
Displays all rows that contain a string of at least 5 consecutive lowercase characters for each string.
2. See if a program is running
ps –ef|grep tomcat
See all processes related to Tomcat
3. Terminating a thread
kill -9 19979
Thread that terminates thread number bit 19979
4. View files, including hidden files
ls -al
5. Current working directory
pwd
6. Copying files
cp source dest
Copying files
cp -r sourceFolder targetFolder
Recursively copy entire folders
scp sourecFile [email protected]:remoteAddr
Remote Copy
7. Create a Directory
mkdir newfolder
8. Deleting a directory
rmdir deleteEmptyFolder
Delete Empty directory rm -rf deleteFile
recursively delete all contents in directory
9. Move files
mv /temp/movefile /targetFolder
10. Re-order
mv oldNameFile newNameFile
11. Switch Users
su -username
12. Modify File Permissions
chmod 777 file.java
File.java permission-rwxrwxrwx,r means read, w indicates write, X is executable
13. Compressing files
tar -czf test.tar.gz /test1 /test2
14. List Compressed Files
tar -tzf test.tar.gz
15. Extracting Files
tar -xvzf test.tar.gz
16. View file Header 10 lines
head -n 10 example.txt
17. View the end of the file 10 lines
tail -n 10 example.txt
18. View the log type file
tail -f exmaple.log
This command automatically displays what's new, and the screen displays only 10 lines of content (can be set).
19. Execute commands with Super Administrator status
sudo rm a.txt
Delete Files using administrator
20. View Port Usage
netstat -tln | grep 8080
Viewing 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 processes
ps aux
View All Processes
23. List the contents of the directory in a tree view
tree a
Ps:mac using the tree command
24. File download
wget http://file.tgz
Install wget command under Mac
curl http://file.tgz
25. Network detection
ping www.taobao.com
26. Telnet
ssh [email protected]
27. Printing information
echo $JAVA_HOME
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
28.linux Command Learning site:
http://explainshell.com/
Resources:
The Linux port is occupied with the resolved (Error:jboss port is in use. Please check)
Powerful and common commands in Linux: Find, grep
Linux commands
Welcome to add! ~
Beijing Shang Academy-CCTV CCTV net Advertising partners, professional Java training institutions, best-in-word Java training, iOS training, Android training, Hadoop Big Data training, Web front end, 0 yuan admission, first post-employment payment, average employment salary above 9500
Java developer must-have Linux commands