|
As a cross-platform .NET development era developers, some commonly used Linux commands must master. Instant usual development process does not use Linux (Unix) or mac system, also need to master Linux command. Because many servers are Linux systems. Therefore, to and from the server machine, it is necessary through shell commands.
This article does not explain in detail on all commands, just give common usage and interpretation. Specific usage can use --help to view the help.
1. Find File
find / -name filename.txt filename.txt find the file / directory by name.
find. -name "* .xml" recursively find all the xml file
find -name "* .xml" |. xargs grep "hello world" recursive search xml all files contained in the content of hello world
grep -H 'spring' * .xml find it contains some spring xml file
find ./ -size 0 | xargs rm -f & delete files with zero size files
ls -l | grep '.jar' find the current directory of all the jar files
grep 'test' d * d to display all rows in the beginning of the file that contains the test.
grep 'test' aa bb cc show match aa, bb, cc file test line.
grep '[a-z] \ {5 \}' aa show all contain each string of at least five consecutive string of lowercase characters line.
2. Check if a program running
ps -ef | grep mono See all the processes related to mono
3. Termination Thread
kill -9 19979 19979 terminate the thread, bit process
4. Review the files that contain hidden files
ls -al
5. The current working directory
pwd
6. Copy the file
cp source dest Copy files
cp -r sourceFolder targetFolder recursive copy the entire folder
scp sourecFile romoteUserName @ remoteIp: remoteAddr Remote Copy
7. Create a directory
mkdir newfolder
8. Remove directory
rmdir deleteEmptyFolder remove empty directory rm -rf deleteFile recursive directory delete all content
9. Move files
mv / temp / movefile / targetFolder
10. Rename
mv oldNameFile newNameFile
11. Switch user
su -username
12. Modify the file permissions
chmod 777 file.cs //file.cs permission -rwxrwxrwx, r for read, w for write, x for executable
13. archive
tar -czf test.tar.gz / test1 / test2
14. Identify the compressed file list
tar -tzf test.tar.gz
15. Unzip the file
tar -xvzf test.tar.gz
16. View header 10 lines
head -n 10 example.txt
17. Review the end of the file line 10
tail -n 10 example.txt
18. Check the log file type
tail -f exmaple.log // This command will automatically display the new content, the screen only displays 10 lines of the (settable).
19. Use the super administrator Run
sudo rm a.txt use administrator to delete the file
20. See Port occupancy
netstat -tln | grep 8080 8080 View port usage
21. What is the procedure to view the port
lsof -i: 8080
22. Check process
ps aux | grep jexus View jexus process
ps aux view all processes
23. to list the contents of a directory tree
tree a
ps: use the tree command under Mac
24. File Download
wget http: //file.tgz install wget command under mac
curl http: //file.tgz
25. Network Detection
ping www.linuxidc.com
26. Remote Login
ssh userName @ ip
27. Printing Information
Print value echo $ ZOOKEEPER_HOME zookeeper home environment variables
28.Mono common commands
mono, mcs, gmcs, makecert etc.
29. Other Commands
svn git |
|
|
|