Linux servers commonly used commands work summary

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https: //blog.csdn.net/liuxiangyang_/article/details/100407037
concise version of the

hostname # View the computer name
du -sh <directory name> # View the specified directory size
df -h # View the partitions use
fdisk see all partitions -l #
cat / proc / loadavg # View system load
crontab -l # users to view all scheduled tasks
ps aux | grep nginx # query nginx processes are running
netstat -anp | grep: 80 # view the port situation
rm -rf / var / log / httpd / access / * # delete all of the following access log file
tail -f data.log # real-time monitoring log
tail -n 20 fdata.log | grep 'results' --color # find the last 20 lines of the log and search As a result, content marked red
crontab -l # users to view all scheduled tasks
uname -a # View kernel / operating system / CPU information
head -n 5 / etc / issue # check the OS version
cat / proc / cpuinfo # View CPU information
env # View environment variable
free -m # View the amount of memory usage and swap
grep MemTotal / proc / meminfo # view the amount of memory
grep MemFree / proc / meminfo # view the amount of free memory
uptime # View system uptime, number of users, load
cat / proc / loadavg # View system load
mount | column -t # View hanging then the partition status
fdisk -l # View all partition
swapon -s # View all swap partitions
hdparm -i / dev / hda # View disk parameters (only for IDE devices)
dmesg | grep IDE # View start when the device detects conditions IDE
ifconfig # View all the properties of the network interface
iptables -L # View firewall settings
route -n # View the routing table
netstat -lntp # View all listening ports
netstat -antp # view all established connections
netstat -s # View network statistics
ps -ef # view all processes
top # display real-time process status
w # view active user
id <user name> # display the user information
last # view the user login log
cut -d: -f1 / etc / passwd # View all users of the system
cut -d: -f1 / etc / group # View all system groups
lspci -tv # list all PCI devices
lsusb -tv # lists all USB devices
lsmod # loadable kernel modules listed

detailed version

1.linux see if there is a process running the command: for example, whether the query contains process "nginx" keywords
judged by the process
ps aux | nginx grep
PS the AUX | grep nginx | grep -v grep


grep -v grep is a query (grep) the process
ps -C nginx -o pid
after this direct pid returned more suitable way to be used in conjunction with other programs, such as the implementation of this order to get the pid in shell / python script, so according pid to determine whether to start Nginx.
Judging by the port
netstat -anp | grep: 80

2. How do I view the remaining disk space to mount
using the command df -h to view a mounted hard drive.
Red circle mounted display


3. Delete all the contents of this file (log cleaning)
-r is recursive down, no matter how many level directory, be deleted
-f is the direct forcibly removed, without any prompting meaning
delete all the files under the code
RM -rf / var / log / httpd / Access / *
4. View log
scene 1. log real-time monitoring

1 tail -f fdata.log

   

scene 2 last 20 lines of inquiry, and keyword search for "results"

tail -n 20 fdata.log | grep ' The results'

scene 3. query the last 20 lines, and keyword search for "results" and the text marked red

tail -n 20 fdata.log | grep 'results' --color


4. scene last 20 lines of inquiry, and to find keyword results (text marked red), extended up and down two rows

tail -n 20 fdata.log | grep 'results' --color -a2

Scenario 5: When the log file large, with vim Find
1.) open the file

vim fdata.log

2.) to move to the last line of the file

ctrl + g

to see the bottom of the window displays the word, has come to the end of the show on behalf of the file.

3.) Find the nearest key up from the last, N-up point: the penultimate

:? Com.fm.fdata

Guess you like

Origin www.cnblogs.com/purple5252/p/11871076.html