As a Java developer, some commonly used Linux commands must master. Instant usually do not use Linux (Unix) or mac system development process, but also need to master the Linux command. Because many servers are on Linux systems. Therefore, to interact with the machine and the server, it is necessary through the shell command.
This article does not explain in detail on all commands are given only common usage and interpretation. Specific usage can be used to view help -help or direct learning through google search.
1, Find File
find / -name filename.txt find filename.txt file / directory by name.
. find -name "* .xml" recursive search of all the xml files
find -name "* .xml" |. xargs grep "hello world" recursive search xml file contains all the contents of the file hello world of
grep -H 'spring' * .xml xml file to find it contains some of the spring
find ./ -size 0 | xargs rm -f & delete files with zero size files
ls -l | grep '.jar' looks in all the jar files in the directory
grep 'test 'd * to show all files beginning with d rows included in the test.
grep 'test' aa bb cc display lines in the match test of aa, bb, cc file.
grep '[az] {5} ' aa show all rows each string comprising at least 5 contiguous string of lower case characters.
2, to see if a program is running
ps -ef | grep tomcat View all processes related to the tomcat
3, terminate the thread
kill -9 19979 terminate the thread number 19979-bit process
4, view the file that contains hidden files
-to ls
5, the current working directory
pwd
6, copy the file
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 empty directories
rm -rf deleteFile recursive directory delete all content
9, move files
mv /temp/movefile /targetFolder
10, rename
mv oldNameFile newNameFile
11, the user switch
su -username
12, modify the file permissions
Permissions chmod 777 file.java file.java of -rwxrwxrwx, r for read, w for write, x for executable
13, compressed files
takes -czf test.tar.gz / test1 / test2
14, lists the compressed files list
tar -tzf test.tar.gz
15, unzip the file
takes -xvzf test.tar.gz
16, line 10 to view the header
head -n 10 example.txt
17, 10 lines to see the end of file
tail -n 10 example.txt
18, view the log file type
tail -f exmaple.log This command will automatically display the new content, the screen only displays 10 lines of content (settable)
19, use the super administrator command execution
sudo rm a.txt as administrator to delete files
20, view the port occupancy
netstat -tln | grep 8080 view usage port 8080
21, see the port belongs to which program
lsof -i :8080
22, view the process
ps aux | grep java view java process
ps aux view all processes
23 to list the contents of a directory tree view
tree a
24, file download
wget http://file.tgz
curl http://file.tgz
25, network detection
ping www.just-ping.com
26, remote login
ssh userName@ip
27, print information
echo $ JAVA_HOME print the value of java home environment variable
28, java commonly used commands
java javac jps ,jstat ,jmap, jstack
29, other commands
svn git stomach
30, linux command learning website
References:
Linux port is occupied resolved (Error: Please use JBoss Port IS in the Check.)
Http://www.hollischuang.com/archives/239
Linux in a powerful and commonly used commands: the Find, grep
HTTPS: // Linux. CN / Article This article was 1672-1.html-
Linux command
https://blog.csdn.net/tianshijianbing1989/article/details/40780463
Welcome to add! ~