Previously shared a Linux operation command, the content is very complete, but more basic. However, what is used in practice is a little more complicated than that, and this article shares some of the things that development engineers must have

1. Log query

  • Grep “applyId “app.log //applyId indicates the keyword to be queried, and app.log indicates the log name

  • By keyword paging query cat back – n app. Once upon a time log | grep “applyId” | more the above command will be paged output, using the blank space key pages, show more using the enter key

  • By keyword, displaying only the last M line query tail – n M app. The log | grep “applyId” / / M for the number of rows

  • By keyword dynamic display the latest M line check tail -f M app log | grep “applyId” / / M for the number of rows

  • After the log is too much, the related log output to a file to see the cat – n app. The log | grep “applyId” > app – new. The log / / app – new. The log file name

  • Sed -n ‘/2017-10-17 10:10:10/,/2017-10-17 10:15:00/p’ app.log 2017-10-17 10:10:10 and 2017-10-17 10:15:00 must be truly printed out in logs

  • Dynamically output the latest M-line log tail-100f app.log

2. Port query class

  • View the port usage netstat -tln

  • Check the specified port usage netstat ano | grep / 2181 / check 2181 port usage

  • Run the sudo lsof -i :2181 command to check the process that occupies the specified port

3. Check the network connection

  • List all open network connections (TCP and UDP) lsOF -i

  • List all open TCP network connections lsOF -I TCP

  • Lsof -i UDP lists all open UDP network connections

  • Lsof -i TCP :80: indicates the status of the specified TCP ports

  • Lsof -i udp:55: indicates the specified UDP ports

4. View the resource usage

  • View THE CPU usage, memory, virtual memory swapping, and I/O read and write status vmstat 5 // The CPU usage is updated every 5 seconds

  • View the resource usage of each process in the system top // After running the top command, press Shift+M. The display results are sorted by process memory usage

  • Checking the memory usage Free -m // The unit is MB

  • Run the following command to query the disk space usage df -h

5. Process operations

  • According to the name lookup process ps – ef | grep Java / / use the standard format shows ps aux | grep Java / / using the BSD the format of the display

  • Kill -9 PID // PID indicates the process ID

6. Copy files

SCP is a secure form of file replication, based on SSH

  • Copy the local file to the remote machine copy the local file app.config to the remote 192.168.10.190 server /config/ directory SCP /config/app.config [email protected]:/config/ //root is the user name

  • Copy the remote file to the local SCP [email protected]: / config/app. The config/config / / / root is the user name