Linux view current CPU and Memory usage commands

Source: Internet
Author: User
Tags memory usage cpu usage

One, Linux under the memory View command free detailed:


You can use Free-m to view current memory usage in Linux, and the M parameter is displayed in megabytes, examples:

$ free-m Total used free shared buffers cached mem:1002 769 23 2 0 421-/+ buffers/cache:286 715 swap:1153 0 1153
The first part mem line:

Total Memory: 1002M
Number of memory used has used: 769M
Free amount of Memory: 232M
Shared is currently obsolete no, always 0
Buffers Buffer Cache Memory: 62M
Cached Page Cache Memory: 421M

Relationship: Total (1002M) = Used (769M) + Free (232M)

Part II (-/+ Buffers/cache):
(-buffers/cache) Used memory: 286M (refers to the first part of the Mem line in the used-buffers-cached)
(+buffers/cache) Free Memory: 715M (Free + buffers + cached in the first part of the MEM line)

Visible-buffers/cache reflects the memory that is actually eaten by the program, and +buffers/cache reflects the total amount of memory that can be misappropriated.

The third part refers to the exchange zoning
The results of Part One (MEM) and Part II (-/+ Buffers/cache) are related to why used and free are so strange.
In fact, we can explain it from two aspects.
The parameters of mem for the operating system. Buffers/cached is used, so it thinks free is only 232.
For the application (-/+ Buffers/cach). buffers/cached is equivalent because buffer/cached is designed to improve the performance of the program, and buffer/cached will be used quickly when the program is using memory.

So, to apply to see, to (-/+ Buffers/cache) free and used mainly. So let's look at this. Also tell us some common sense. Linux has done a lot of careful design to improve disk and memory access efficiency,
In addition to caching dentry (for VFS, speeding file path names to Inode conversions), two main cache types are taken: Buffer cache and Page cache. The former is read and write to disk block, the latter is read and write to the file inode. These cache can effectively shorten the I/O system calls (such as read,write,getdents) time.

Remember that memory is used, not taken. Unlike Windows, no matter how much your real physical memory is, he takes the hard drive to swap files for reading. This is why Windows often prompts for the lack of virtual space. You think,
How boring, in the memory and most of the time, take out a part of the hard disk space to act as memory. How can the hard disk be faster than the memory. So we look at Linux, as long as we don't swap space, we don't have to worry about too little memory. If you often
Swap is a lot, and you might want to consider adding physical memory. This is the standard for Linux to see if memory is enough

Second, view the CPU current usage command.

During system maintenance, you may need to look at the CPU usage at any time, and analyze the system condition according to the corresponding information. In CentOS, you can view CPU usage through the top command. When you run the top command, the CPU usage status is displayed in full screen and in a conversational mode-with the command based on top, you can control how the display is displayed, and so on. The command to exit Top is Q (hit Q key once in top run).

Action Example:

Enter top on the command line

You can start top

Top Full Screen Dialog mode can be divided into 3 parts: System Information Bar, command input bar, process list bar.

The first part--The top System Information Bar:

First line (top):

"00:11:04" is the current moment of the system;

"3:35" to the current operating time after the system is started;

"2 users" for the current user login to the system, or, more specifically, the number of users login to the user's terminal-the same user at the same time to the system more than one terminal connection will be considered as multiple users connected to the system, where the number of users will also appear as the number of terminals;

"Load average" is the average of the current system load, the following three values are 1 minutes ago, 5 minutes ago, 15 minutes before the average process, the general can be considered that the number of CPUs, the CPU will be more laborious load the current system contains processes;

Second line (Tasks):

"Total" is the current number of system processes;

"1 Running" is the number of processes currently running;

"Sleeping" is the number of processes currently in the waiting state;

"0 stoped" is the number of system processes stopped;

"0 Zombie" for the number of recovered processes;

Third line (Cpus):

The current utilization rate of CPU is indicated respectively.

Line Four (MEM):

Represents the total amount of memory, current usage, amount of idle memory, and the amount of RAM used in the buffer;

Line Five (Swap):

Represents a category with line fourth (MEM), but this reflects the usage of swap partitions (swap). Typically, swap partitions (swap) are used frequently, and are considered to be the result of insufficient physical memory.

Part Two--internal command prompt bar in the middle section:

The top command allows you to control how the process is displayed through the top's internal commands. The internal command follows the following table:

S

-Change the frequency of the screen update

L-The representation of the first line top information on the first section is closed or opened

T-closes or opens the first part the second line of Tasks and third line Cpus information representation

M-to close or open the first section the representation of the four-line Mem and fifth-line Swap information

N-Arranges the list of processes in the order of the PID size (Part III)

P-Arranges the list of processes in the order of CPU usage (Part III)

M-Arranges the list of processes in the Order of Memory occupancy (Part III)

H-Show help

N-Sets the number of processes displayed in the process list

Q-Exit Top

S-

Change the screen update cycle

Part three--The process list bar in the bottom section:

The PID-Differentiated process list updates periodically according to the set of screens. You can control how this is displayed through the top internal command

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.