Common linux commands at work

In the past year, the number of new requirements and iterations in the project has gradually stabilized, and the usual work is to solve defects and bugs, which involves a lot of debugging work on the Linux server, so I sorted out the usual work. The more used linux commands are for future reference. The details are as follows:

tar -czvf webapps.tar.gz webapps
compresses the folder named webapps into a tar package named webapps.tar.gz

tar -xzvf file.tar.gz // 解压 tar.gz

ls
lists the filenames of non-hidden files in the current directory, sorted by filename

ll
list the file names of non-hidden files in the current directory, including the attributes and permissions of the file or directory

du -sh *
view all subdirectory sizes

df -h
to view the disk occupancy

free -m
to view server memory usage

netstat -anp | grep 9100
to see which process is occupied by port 9100

netstat: The command is used to display various network related information, such as network connection, routing table, interface status (Interface Statistics), masquerade connection, Multicast Memberships, etc.

lsof -i:8080
shows the process of port 8080

ps -ef | grep tomcat
to view all processes related to tomcat

ps -ef | grep 27910
to view the running information of process ID 27910

ps -ef | grep php
to view all processes about php

ps aux | grep your tomcat directory name
to find the thread of tomcat

ps: used to list those processes currently running in the system

You can find the specific deployment path of the corresponding service through the port number by means of netstat -apn|grep port number + ps ef | grep thread number

grep -rn 'nginx.pid' conf/
Search the file path with "nginx.pid" in the file under the conf folder

chmod 777 *sh
gives full permissions to all sh files in this folder

cd /
go back to the root directory

rz
upload file

rz -y
upload and replace files with the same name

find . |xargs grep "error"
searches all files in the current directory for files with the string error

mv project.war project-tomcat-8080/webapps/
"cut" project.war directly to the webapps directory under project-tomcat-8080

rm -rf
delete the folder and all files under it
rm -f
delete the file
rm -rf * 
delete all files in the current directory

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326169770&siteId=291194637