When you’re new to Linux, one of the first things you’ll want to know is how to check how much memory (RAM) your system is using, like you would with Task Manager in Windows. This guide shows you the most useful commands to check memory usage from the command line in Ubuntu and other Linux distributions.
Open a terminal (press Ctrl + Alt + T in Ubuntu) and try the commands below.
1. free
The free command shows the total, used and free physical memory (RAM) and swap space, as well as the memory used for buffers and cache.
The easiest way to use it is with the -h (human-readable) option, which shows sizes in MB or GB:
free -hTo show values in megabytes, use:
free -mLook at the available column: it shows how much memory is available for new programs, including memory that Linux is using for cache but can free up when needed.
Other useful options:
- -b, -k, -m, -g: show values in bytes, kilobytes, megabytes or gigabytes
- -t: add a line with the total of RAM and swap
- -s N: repeat the output every N seconds (press Ctrl + C to stop)
2. vmstat
The vmstat command reports information about processes, memory, paging, disk I/O and CPU activity. It’s useful for watching memory usage over time.
vmstat 5This prints a new line every 5 seconds. To print 10 updates and then stop, use:
vmstat 5 10Other options: -s shows a table of memory statistics and event counters, and -S M shows values in megabytes.
3. top
The top command shows running processes in real time, along with total memory and swap usage at the top of the screen.
topWhile top is running, press Shift + M to sort processes by memory usage, Shift + P to sort by CPU usage, and q to quit. You can also start it with options, for example top -d 2 to refresh every 2 seconds, or top -p 1234 to monitor only the process with ID 1234.
4. htop (Easier to Read)
htop is a more user-friendly version of top, with colored memory and CPU bars and mouse support. Install it with sudo apt install htop and run:
htopIf you prefer a graphical tool, open the System Monitor app in Ubuntu and go to the Resources tab.


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.
I would suggest replacing top with htop and vmstat with dstat …
[…] This guide will show you how to check memory usage in Linux using the command line. There are three commands which will do the task. Free ; Vmstat ; Top . Command Line Command: … I like Your Article about How to check Memory Usage in Linux via Command Line (Ubuntu) … – read more […]