How To Check Memory Usage on Linux and Unix Servers

Unix is a computer operating system developed by a team of employees at AT&T working at Bell Labs in 1969. Released in 1971, it was acquired by Novell in 1994 and transferred later to The Open Group. Unix has a Single UNIX Specification implemented worldwide and only those systems that conform to this standard may use the trademark. Other systems may be called Unix-like, such as Linux.

The Unix operating systems are used in workstations and servers and are designed to be portable, can perform several tasks simultaneously and be used by several users at any time.

Linux is a derivative of the Unix computer operating system whose development is one of the most popular examples of the free and open-source software alliance. The Linux name came from Linus Torvalds who originally wrote the program in 1991.  Today, the Linux system is popularly used from embedded systems such as those used in smartphones, to supercomputers like the Jaguar, the world’s fastest supercomputer (as of November 2009) being used by the Oak Ridge National Laboratory and the soon to be released (2011) Sequioa by IBM, said to be the world’s most powerful supercomputer. Linux is also the base for the server and software combination of LAMP (Linux, Apache, MySQL, Perl/PHP/Python), a favorite of developers and the most common platform for web hosting services. The Linux distribution has also been adopted by several countries. In 2008, almost 60% of all web servers run on Linux.

Memory is one of the most vital resources on a server. It ensures the fast and unobstructed system operation. It is therefore essential for a server to have ample available memory, especially those servers that are used for database and web hosting.

A Unix or Linux server apportions all available memory to administration and other programs running on the server and only leaves a buffer of about 5 megabytes.  When this happens you need to check which resources are hoarding or using a lot of server memory. There are several tools and commands available to the administrator to check this. Here is what you need to do:

1.    meminfo. This command will give you all the information on your server’s memory usage. To use this command, just type cat/proc/meminfo.

2.    free. This command displays the total amount of used and free physical memory, swap memory and the buffers used by the server kernel. To use this command, type the following for additional options:

  • free -m or free(space)-m. This will allow you to see your physical memory in megabytes.
  • free -m -t or free(space)-m(space)-t. This command is almost the same as the previous one but adds another line to show you the grand total as well as the totals for the used and free memory.

3.    vmstat.  When you use this command, your server will give you a report on processes, paging space, swap, cache, buffer and free memory, activity of disk IO, traps, interrupts, context switches and the activity of your central processing unit.

4.    top. Using this command will give you a real-time view of your systems as it runs. This will show you a summary and a list of currently managed tasks done by the Linux/Unix server kernel. It will also show you the information on used and free physical memory, swap memory and buffers as well as cached memory.

5.    ps aux.  The letters ps stand for process status. When you type this command inside the command shell, you will see a display of all the running processes and programs running on the server and how much memory these are using. With this command you can see the percentage of memory resource being used by tasks and programs and be able to identify those that hog a lot of memory and check them.

The above commands will generally work for most servers running on Unix and Linux operating systems and their variants.


Share this article!

Follow us!

Find more helpful articles: