Find Files
find / -name filename.txt filename.txt find files in the / directory by name.
find. -name "* .xml" recursively find all the xml file
. Find -name "*" | xargs grep "hello" xml file recursive search of all files contained in the content of hello world
grep -H 'spring' * .xml find so some xml file that contains the spring
find ./ -size 0 | xargs rm -f & delete files with zero size files
ls -l | grep '.jar' to find all the current jar file directory
grep 'test' d * to show all files beginning with d rows included in the test.
grep 'test' aa bb cc matching test in the display line aa, bb, cc file.
grep '[az] {5}' aa show all rows each string comprising at least 5 contiguous string of lower case characters.
Check if a program running
ps -ef | grep tomcat tomcat view of all relevant processes
ps -ef | grep --color java highlighted keywords to query (see all start the service)
Terminate the process
- kill -9 19979 terminate the thread number of process-bit 19979
View files, containing hidden files
- -to ls
The current working directory
- pwd
Copy files
cp source dest Copy files
cp -r sourceFolder targetFolder recursively copy the entire folder
scp fileName root @ ip: / addr Remote Copy
Create a directory
- mkdir newfolder
Remove directory
delete empty directories rmdir deleteEmptyFolder
rm -rf deleteFile recursive directory delete all content
Moving Files
- mv /temp/movefile /targetFolder
Rename
mv oldNameFile newNameFile
Switch User
su -username
Modify file permissions
- Permissions chmod 777 file.java file.java of -rwxrwxrwx, r for read, w for write, x for executable
Compressed file
- takes -czf test.tar.gz / test1 / test2
Lists the compressed files list
- tar -tzf test.tar.gz
unzip files
- takes -xvzf test.tar.gz
10 lines before viewing files
- head -n 10 example.txt
After a review of files row 10
- tail -n 10 example.txt
View Log Last Updated
- tail -f exmaple.log This command will automatically display the new content, the screen only displays 10 lines of content (can be set).
Execute commands using a super administrator
- sudo rm a.txt as administrator to delete files
View port occupancy
- netstat -tln | grep 8080 view usage port 8080
View port belongs to which process
- lsof -i :8080
View the process
ps aux | grep java view java process
ps aux view all processes
List directory in a tree format
tree a
PS: Mac using the tree under the command
document dowload
wget http://file.tgz
PS: Mac install wget command under
curl http://file.tgz
Network Detection
- ping www.just-ping.com
Remote Login
- ssh userName@ip
Print information
- echo $ JAVA_HOME print the value of java home environment variable
Java common commands
java
javac
Jvp
jps
jstat
jmap
jstack
Other commands
svn
git
maven
Annex: extracting archive command Details
1. Compression
tar -cvf jpg.tar * .jpg // directory to package all jpg files into tar.jpg
After the tar -czf jpg.tar.gz * .jpg // directory to package all jpg files into jpg.tar, and its use gzip compression to generate a gzip compressed package named jpg.tar.gz
After the tar -cjf jpg.tar.bz2 * .jpg // directory to package all jpg files into jpg.tar, and it is compressed with bzip2, to generate a bzip2 compressed package named jpg.tar.bz2
After the tar -cZf jpg.tar.Z * .jpg // directory to package all jpg files into jpg.tar, and its use compress compression, produces a umcompress compressed package named jpg.tar.Z
rar a jpg.rar * .jpg // rar compressed format, you need to download rar for linux
zip jpg.zip * .jpg // compressed zip format, you need to download the zip for linux
2. Extract
tar -xvf file.tar // extract the tar package
tar -xzvf file.tar.gz // 解压 tar.gz
tar -xjvf file.tar.bz2 // 解压 tar.bz2
tar -xZvf file.tar.Z // unpack tar.Z
unrar e file.rar // Kai压 rar
unzip file.zip // extract the zip