Monitoring Memory Usage in Ubuntu: 2 Useful Linux Commands

July 25, 2012

Let’s say you would like to monitor the memory usage of your system over a period of time (e.g., a snapshot of your resources being used every 2 seconds). You want to start monitoring, execute a few commands/processes, and then see how much memory is used.

Enter the watch+free commands

At your command prompt, you would type:

watch -n 2 free -m

Then you would see something like:

watch utility screenshot

The watch command gives you the updates every 2 seconds, and the free command lets you see how much memory is free and being used. You should look at the -/+ buffers/cache line under the free column to see how much memory you have available for application usage. If you just look at the free column of the Mem: line, it may look like you don’t have a lot of memory available because Linux uses a ton of memory for disk caching.

If you’re interested in a list of system processes, try the htop command.

Htop is a little different than top in that it provides a list of all running processes, not just the most CPU intensive ones the way top does. Htop is also in color and is easier to look at. To install it at the command line in Ubuntu, type:

sudo apt-get install htop

Do you have any Linux memory tricks? Leave a comment below.


Profile picture

Written by Bruce Park who lives and works in the USA building useful things. He is sometimes around on Twitter.