Home / Linux / How to check Memory Usage in Linux via Command Line (Ubuntu)

How to check Memory Usage in Linux via Command Line (Ubuntu)

Most of our readers are really interested in Linux and kept on requesting me to post articles on basic of Linux for newbie. We do understand the problem of newbie and we here at Techie Inspire always tries to be simple and informative. Generally, when newbies use Linux for first time, they start wondering about how to check memory usage, like we do in windows using the task manager. This guide will show you how to check memory usage in Linux using the command line.

how to check memory usage in linux

 

There are three commands which will do the task

  1. Free
  2. Vmstat
  3. Top

 

Command Line Command:

 

  • Free

Free displays the total amount of free and used physical memory and swap space in the system, as well as the buffers and cache consumed by the kernel.

Syntax of free

free -[options]

Type below command in command line, It will display a table of six column and three rows of data, all expressed in kilobytes.

free

Type below command in command line, It will display data in megabyte (MB)

free -m

Free linux command

Other options that you can try,

-b – Displays output in bytes

-k – Display output in Kilobytes (KB), This is the default.

-g – Display output in Kilobytes (GB).

-l – Display low vs. high memory usage.

-t – Display total summary for physical memory + swap space.

-s n, -repeat=n

Repeat, pausing every n seconds in-between.

-V – version

Display version information and exit.

 

  • vmstat

vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. This could also help in instant report on memory usage.

Syntax of vmstat

vmstat [-n] [delay [ count]]

Type below command in command line, It will display vmstat with 5 second delay.

vmstat 5

Type below command in command line, It will display vmstat with 5 second delay repeat up to 10 times

vmstat 5 10

vmstat linux command

Other options that you can try,

-n switch causes the header to be displayed only once rather than

periodically.

-s switch displays a table of various event counters and memory

statistics.

-V switch results in displaying version information.

 

 

  • Top

“Top” command display cpu processes activity in real time, It shows the top most cpu processes which are running on your system. It also helps to sort the task by memory usage, Cpu usage and real-time basis. Besides of displaying process information, it furthermore displays free memory of physical as well as swap.

Syntax of top

top -[options]

Type below command in command line, It will display real-time CPU processes

top

top linux command

Other options that you can try,

-d         Specifies the delay between screen updates. You can change this with the s interactive command.

-p         Monitor only processes with given process id. This flag can be given up to twenty times. This option is neither available interactively nor can it be put into the configuration file.

-q         This causes top to refresh without any delay. If the caller has superuser privileges, top runs with the highest possible priority.

-C         Display total CPU states instead of individual CPUs. This option only affects SMP systems.

 

If you find above article on How to check memory usage in linux interesting then please subscribe to Techie Inspire…

About Kroshan

Roshan Karkera a.k.a. k.roshan. Blogger by passion and software engineer by profession. He believes in sharing knowledge, which made him to start his own blog. He is very much keen & passionate about new technology & Science. If you'd like to connect with him, follow at Google plus or Twitter.
  • I am writing to let you understand of the notable experience our princess experienced checking your blog. She noticed a lot of details, most notably how it is like to possess an amazing giving spirit to let a number of people completely know certain tricky things. You undoubtedly did more than our expectations. Thanks for displaying these warm and helpful, dependable, educational not to mention fun guidance on that topic to Janet.

  • You completed certain excellent points there. I did searching on the topic matter and identified most persons will go together together with your weblog

  • I cannot WAIT to read more of this. I mean, you just know so much about this. So much of it Ive never even thought of. You sure did put a new twist on something that Ive heard so much about. I dont believe Ive actually read anything that does this subject as good justice as you just did.
    fc forex
    [url=http://www.liveinternet.ro/tranzactii-forex-bursa-romania/]roboti forex[/url]
    http://www.liveinternet.ro/tranzactii-forex-bursa-romania/ – cum functioneaza forex

  • I like Your Article about How to check Memory Usage in Linux via Command Line (Ubuntu) Perfect just what I was searching for! .

  • I simply want to mention I am very new to blogging and site-building and absolutely loved this web site. Most likely I’m planning to bookmark your blog . You really come with superb articles. Cheers for sharing your web page.

  • Excellent job right here. I genuinely enjoyed what you had to say. Keep going because you absolutely bring a new voice to this topic. Not many people would say what youve said and still make it interesting. Well, at least Im interested. Cant wait to see additional of this from you.

  • Name

    I would suggest replacing top with htop and vmstat with dstat …

  • Pingback: ubuntu check ram usage command lin? | Askjis()