1. vmstat reports virtual memory statistics. vmstat [-V] [-n] [delay [count] delay is the delay time between two outputs; count refers to the number of times statistics are made at this interval. Example: vmstat-n3 (refresh once every 3 seconds) procs -------...
1. vmstat reports virtual memory statistics
Vmstat [-V] [-n] [delay [count] delay is the delay time between two outputs. count is the number of times counted based on this interval. Example: vmstat-n 3 (refresh once every 3 seconds)
Procs ----------- memory ---------- --- swap -- ----- io ---- system -- ---- cpu ---
R B swpd free buff cache si so bi bo in cs us sy id wa
1 0 144 186164 105252 2386848 0 0 18 166 83 2 48 21 31 0
2 0 144 189620 105252 2386848 0 0 177 1039 34 10 56 0
0 0 144 214324 105252 0 0 0 10 2386848 32 5 63 0
Procs
R: number of processes waiting for running B: number of processes in non-interrupted sleep state w: number of processes that can be swapped out. This number is calculated by linux, but linux does not exhaust swap space.
Memory
Swpd: virtual memory usage, in KB
Free: Idle memory, in KB
Buff: the number of memories used as Cache. unit: KB
Swap
Si: Number of swap pages from disk swap to memory, measured in KB/second
So: the number of pages exchanged from the memory to the disk. unit: KB/second
IO
Bi: number of blocks sent to block devices. unit: Block/second
Bo: number of blocks received from the block device. unit: Block/second
System
In: The number of interrupts per second, including clock interruptions.
Cs: number of environment (context) switches per second
CPU
Display by CPU usage percentage
Us: CPU usage time
Sy: CPU system usage time
Id: idle time
If the "us + sys" 80 in a multi-user environment is used, the process will wait for time in the running queue, and the response time and throughput will decrease. Wa> 40 indicates that there may be no unreasonable balance between disk io or frequent disk operations.
2. run lsmod to check the number of loaded modules in linux.
For example, we can check whether the module ip_vs has been loaded in the system. ipvsadm: lsmod | grep ip_vs
3. lsof (list open files) is a tool used to list open files in the current system.
Lsof is commonly used to find the name and number of files opened by an application. It can be used to find out where a specific application records log data or is tracking a problem.
Lsof-c string displays all open files of the process whose COMMAND column contains the specified characters.
Lsof-u username: displays the files opened by the user process
Lsof-g gid: displays the processes that belong to the gid.
Lsof + d/DIR/displays files opened by processes in the directory
Lsof + D/DIR/is the same as above, but all directories under the directory will be searched for a relatively long time
Lsof-d FD displays the process of the specified file descriptor
Lsof-n does not convert the IP address to the hostname. the-n parameter is not added by default.
Lsof-I is used to display qualified processes
For example, check the current running status of port 22.
# Lsof-I: 22
View the txt file opened by the root user process:
# Lsof-a-u root-d txt
When detaching a file system, if the file system contains any open files, the operation usually fails. Then, you can use lsof to find out which processes are currently using the file system to be detached, as shown below:
# Lsof/GTES11/
When a file in the system is accidentally deleted, as long as there are other processes in the system accessing the file, we can use lsof to restore the file content from the/proc directory. If the/var/log/messages file is deleted due to misoperations, the methods for restoring the/var/log/messages file are as follows:
First, use lsof to check whether a process opens the/var/logmessages file, as shown below:
# Lsof | grep/var/log/messages
Syslogd 1283 root 2 w REG 5381017 1773647/var/log/messages (deleted)
From the above information, we can see that the file descriptor of the PID 1283 (syslogd) open file is 2. You can also see that/var/log/messages has been marked as deleted. Therefore, we can view the corresponding information in/proc/1283/fd/2 (each file named by number under fd represents the file descriptor corresponding to the process), as follows:
# Head-n 10/proc/1283/fd/2
From the above information, you can view/proc/8663/fd/15 to obtain the data to be restored. If you can view the corresponding data through the file descriptor, you can use I/O redirection to copy it to the file, such:
Cat/proc/1283/fd/2>/var/log/messages
4. dmidecode: a management system that helps collect computer system information
Dmidecode-s system-serial-number // display the system serial number-s, -- string KEYWORD Only display the value of the given DMI string Only displays the information of the specified DMI string
Dmidecode-t memory // display the memory information-t, -- type TYPE Only display the entries of given type # Only display the information of the specified entry
Dmidecode-t 11 # display OEM information
5. mii-tool: this command is used to set the Nic working mode in Linux.
(1) view the network card working mode. enter the command: # mii-tool-v "100BaseTx-FD" to indicate 100 M Full Duplex.
(2) to change the Nic working mode, enter the command: # mii-tool-F media [interface]
For example, to set the network card to work in 10 m half duplex mode, enter the command: # mii-tool-F 10baseT-HD eth0
(3) restore the adaptive working mode of the network adapter. run the following command: # mii-tool-r eth0.
6. sort ~ /. Bash_history | uniq-c | sort-nr | head // You can view the commands most frequently used by system users. among them, uniq-c prints the number of times each duplicate row appears. Sort-n is sorted by numerical value-r is displayed in reverse order.
7. view the system load value at uptime: 1, 5, 15 minutes
/Proc/loadavg also displays the system load value
8. display the 10 processes that consume the most memory/CPU resources
Ps aux | sort-nk + 4 | tail
Ps aux | sort-nk + 3 | tail
9. view the number of concurrent apache requests and their TCP connection status
Netstat-n | awk '/^ tcp/{++ S [$ NF]} END {for (a in S) print a, S [a]}'
10. rename *. sh in the current directory to *. SH.
Find.-name "*. sh" | sed's/(. *). sh/mv? 1. SH/'| sh
Find.-name "*. sh" | sed's/(. *). sh/mv & 1. SH/'| sh
11. execute a remote program through ssh and display it locally.
Ssh-n-l root 10.48.30.197 "ls-l/root"
12. share files in the current folder as http
Python-m SimpleHTTPServer
Enter http: // IP: 8000/in the browser to download the file in the current directory.
13. locate allows users to quickly search for specified files in the file system.
Locate-n 100 a. out: searches for all files named a. out, but displays a maximum of 100 files.
Locate chdrv: Search for all chdrv files.
Find/-name "* chdrv *"-print is the same as above. difference: find only looks for specific files and directories, and the displayed number is smaller than the preceding command.
14. obtain the program name list by which. The specific path of the command location.
Root @ svn-30-194 :~ # Which top
/Usr/bin/top
15. disable or enable ping in Linux
# Echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
If you want to restore, as long:
# Echo 0>/proc/sys/net/ipv4/icmp_echo_ignore_all
Author "lovecode"