Linux command to view the memory usage and system resources of processes

Source: Internet
Author: User
Use & 039; top-I & 039; to check how many processes are Running. the system may have memory or IO bottlenecks.

Use 'top-I 'to check how many processes are Running. the system may have memory or I/O bottlenecks. use free to check whether the system memory usage is high, use iostat to check the I/O load...

Another method is ps-ef | sort-k7, which sorts processes by running time and determines which process consumes the most cpu time.

Top:
Main parameters
D: specify the update interval, in seconds.
Q: There are no delayed updates. If a super user exists, the top command is executed in the highest priority order.
C: displays the complete process path and name.
S: the accumulation mode, which accumulates the CPU time of the completed or disappearing sub-itinerary.
S: security mode.
I: No Idle (Idle) or useless (Zombie) itinerary is displayed.
N: displays the number of updates. after the update is completed, it will exit
Display parameters:
PID (Process ID): Process ID.
USER: the USER name of the process owner.
PR: process priority.
NI: the priority value of the process.
VIRT: virtual memory occupied by the process.
RES: the physical memory occupied by the process.
SHR: the shared memory value used by the process.
S: Process Status. S indicates sleep, R indicates running, Z indicates frozen, and N indicates that the priority of the process is negative.
% CPU: CPU usage occupied by the process.
% MEM: Percentage of physical memory and total memory occupied by the process.
TIME +: The total cpu time occupied by the process after it is started.
Command: The name of the startup Command that the process starts. if this line does not appear, the process has a complete Command line.
Some interactive commands can be used to complete other parameter functions during the use of the top command. These commands are started by using the shortcut key.
<空格> : Refresh immediately.
P: Sort by CPU usage.
T: Sort by time and accumulated time.
Q: exit the top command.
M: Switch to display memory information.
T: Process and CPU status information is displayed during switchover.
C: switch the display command name and the complete command line.
M: Sort by memory size.
W: write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.
Free
1. Role
The free command is used to display memory usage. The permission is applied to all users.
2. Format
Free [-B-k-m] [-o] [-s delay] [-t] [-V]
3. main parameters
-B-k-m: memory usage is displayed in bytes (KB, MB.
-S delay: the number of seconds to display the memory usage.
-T: displays the total memory column.
-O: The buffer adjustment column is not displayed.

Uptime

18:59:15 up 25 min, 2 users, load average: 1.23, 1.32, 1.21
Current time
How long has the system been running?
Number of connected users
System load in the last minute, five minutes, and fifteen minutes
Parameter:-V displays version information.

Vmstat

Procs ----------- memory ---------- --- swap -- ----- io ---- system -- ---- cpu ----
R B swpd free buff cache si so bi bo in cs us sy id wa
0 1 24980 10792 8296 47316 5 19 205 1161 698 26 3 1 70
1. observe disk activity
Disk activity is mainly based on the following indicators:
Bi: the number of blocks read from the disk per second (blocks/s ). The larger the number, the more disk read activity.
Bo: the number of blocks written to the disk per second (blocks/s ). The larger the number, the more disk write activity.
Wa: percentage of time when the cpu waits for disk I/O (pending disk IO. The larger the number, the more serious the file system activity hinders the cpu, because the cpu is waiting for the slow disk system to provide data. It is ideal to set wa to 0. If wa is often greater than 10, the file system may need to adjust its performance.
2. observe cpu activity
Vmstat better reflects cpu usage than top:
Us: the cpu usage time ratio of the user program. The larger the number, the busier the user process.
Sy: cpu usage time ratio for system calls. Note that NFS runs in the kernel, so the cpu time occupied by NFS activity is reflected in sy. If this number is large, you need to consider whether a kernel process is heavy, for example, NFS tasks. If both us and sy are large, you need to consider separating some user programs from other servers to avoid mutual influence.
Id: Percentage of idle cpu time.
Wa: percentage of time when the cpu waits for pending disk IO.

Iostat

Used to count CPU usage and tty device, hard disk and CD-ROM I/0 count
Parameters:
-C: only CPU rows are displayed.
-D: Display disk lines
-K displays disk output in kilobytes
-T include the timestamp in the output
-X includes extended disk metrics in the output
Avg-cpu: % user % nice % sys % iowait % idle
20.25 0.18 2.61 76.39 0.57
% Percentage of CPU idle time when iowait waits for local I/O
% Percentage of idle CPU time when idle does not wait for local I/O
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Hda 9.86 284.34 84.48 685407 2036
Transmission per second (tps), 512 bytes of block read per second (Blk_read/s), 512 bytes of block write per second (Blk_wrtn/s), and 512 bytes of block read (Blk_read) and the total number of writes (Blk_wrtn.

System
# Uname-a # View kernel/operating system/CPU information
# Head-n 1/etc/issue # view the operating system version
# Cat/proc/cpuinfo # View CPU information
# Hostname # view the computer name
# Lspci-TV # List all PCI devices
# Lsusb-TV # List all USB devices
# Lsmod # List loaded kernel modules
# Env # View environment variables
Resources
# Free-m # View memory usage and swap zone usage
# Df-h # view the usage of each partition
# Du-sh # view the size of a specified directory
# Grep MemTotal/proc/meminfo # View total memory
# Grep MemFree/proc/meminfo # view the amount of idle memory
# Uptime # View system running time, number of users, and load
# Cat/proc/loadavg # View system load
Disks and partitions
# Mount | column-t # view the status of the mounted partition
# Fdisk-l # View all partitions
# Swapon-s # View all swap partitions
# Hdparm-I/dev/hda # View disk parameters (only applicable to IDE devices)
# Dmesg | grep IDE # view the IDE device detection status at startup
Network
# Ifconfig # view the attributes of all network interfaces
# Iptables-L # View firewall settings
# Route-n # view the route table
# Netstat-lntp # View all listening ports
# Netstat-antp # View all established connections
# Netstat-s # View network statistics
Process
# Ps-ef # View all processes
# Top # Display process status in real time
User
# W # View active users
# Id # View specified user information
# Last # View user logon logs
# Cut-d:-f1/etc/passwd # View all users in the system
# Cut-d:-f1/etc/group # View all groups in the system
# Crontab-l # view the scheduled tasks of the current user
Service
# Chkconfig -- list # list all System Services
# Chkconfig -- list | grep on # list all started System Services
Program
# Rpm-qa # View all installed software packages

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.