Linux free command to display idle and used memory in the system

Source: Internet
Author: User
Tags memory usage readable server memory

The system administrator must maintain the healthy operation of their servers. One important part of this is memory. When server memory usage is too high, it degrades server performance. Linux has a tool called free to monitor memory usage.

What's the free command?

The free command is a tool that displays the amount of idle and used memory in the system. The output of the free command is similar to the top command. Most Linux distributions already contain the free command.

How to Run Free

To run, simply enter free in the console. Run with no options displays a default output in kilobytes.

$ free

From the screenshot above we see:

Memory (in KB)

Total (All): 1026740

Used (used): 843396

Free (available): 183344

Shared (shared): 0

Buffers (block device buffer): 52704

Cached (file cache): 376384

Buffers refers to the size of the buffer used to make a block device, he only records the file system metadata and tracking in-flight pages.

Cached is used to buffer files.

That is to say: buffers is used to store, what content in the directory, permissions and so on. and cached is directly used to memorize the files we open.

Swap (in KB)

Total (All): 1045500

Used (used): 3376

Free (available): 1042124

When you see a buffer/cache free space or a low free space for swap, the memory needs to be upgraded. This means that memory utilization is high. Note that the shared (shared) memory column should be ignored because it has been discarded.

Displaying memory information in another unit

As we mentioned earlier, the default free will display information in kilobytes. Free also provides us with B (b), K (KB), M (MB), G (GB) And–tera (TB) units. To display the units we want, simply select one and keep up with the free behind. The following is an output sample in megabytes (MB).

$ free-m

The same technique applies to-B, K, G, and –tera options.

Display memory information in a human readable manner

Free also offers the-h option, which means that the-H option may not exist on the system and has been replaced by-M. So how does this differ from other options, such as the-M (MB) option? The most visible difference is that the-h option adds a human-readable unit after the number. Let's look at an example.

$ free-h

As we saw together, this is the G (GB) Letter after the 1,0 number. When the numbers aren't up to GB, free is smart enough to know and keep up with the right units behind each number. The back of M-digit 929 tells us that it has 929MB (929 number tell us its 969 megabytes, which should be an input error).

Interval showing free

As a state-checking tool, the best way to count memory utilization is to use a delay interval. In so doing, we can use the-s option to keep up with the number of n seconds we want to interval. We can combine several options behind to make the output meet our needs. If we want to count memory utilization every 3 seconds and be suitable for human readable, then do it like this:

$ FREE-HS 3

Show high and low memory utilization

If we want to know the high and low memory statistics, we can use the-l option. Here is an example.

$ free-l

Show Linux Full Memory

If we need total information for each column, we can follow the-t option after the free command. This adds an extra line to the bottom of the word.

$ free-t

Summarize

The free command is also a simple statistical tool for statistical memory utilization, in addition to Vmstat. With this you can quickly view your Linux memory information. The free command uses/proc/meminfo as a benchmark to display memory utilization information. As always, you can enter a man's free at the console to get more information about it.

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.