How to Show Ubuntu, Centos, Linux Real Memory Usage

Memory is a crucial resource on any server that influences its smooth and swift operability. Thus, it is important that you know that amount of memory being used at any given time. Linux – as well as CentOS (widely used in cPanel/Plesk servers) – has several commands that let you check the memory usage on the server.


The free command can used to gauge the amount of memory being used and the amount that is free out of the total RAM in the system. It also shows auxiliary information regarding shared and cached memory, and buffer and swap space.

    free -[options]
    Usage / Examples
    free -m

This shows information regarding the physical memory.

    free -m -s 5
    This activates a repetitive pooling delay with a period of 5 seconds, and displays the current memory status. You can enter a floating-point number to specify the delay (5 seconds in this case).
    free -t -m
    By adding the -t switch to the previous command, you can view the total amount of physical and swap memory space.


vmstat gives you a comprehensive statistical report on the virtual memory. This includes information regarding various processes, different kinds of memory, and disk and CPU activity among a host of other things. With vmstat, administrators can access instantaneous reports regarding memory usage.

    vmstat -[options] [delay count]
    Usage / Examples
    Simply entering vmstat displays a report that uses averages since the last startup.
    vmstat 5
    This will pool system resources for sampling periods of 5 seconds each, and display the stats accordingly.


The top command shows the current tasks being run by the kernel along with system information in real-time. The information displayed by the top command include the total and available free memory space, swap and buffer spaces, and the cached memory.

    Syntax / Usage / Example
    The usage and syntax of this command is relatively simple – simply enter top at the prompt.

ps aux

This command gives snapshot information of current processes. The basic advantage of using ps is that the system administrator can find out the process-specific memory usage. As this command shows the amount of memory that each process is using, the memory extensive processes can be easily identified.

    Syntax / Usage / Examples
    ps aux
    The aux part of the above line is actually an option switch for the ps command that asks ps to list every process that is running.
    In order to view the memory usage by category – for instance, Apache, MySQL or Java, use the following command:
    ps aux | awk ‘{print $4″\t”$11}’ | sort | uniq -c | awk ‘{print $2″ “$1” “$3}’ | sort -nr

All of the above methods of checking memory usage work on most Unix/Linux systems. However, you have to note that if you use a Virtual Private Server, a Virtual Dedicated Server, or a Hybrid Server, the commands listed here will show information pertaining to the entire server – i.e. it will take into account the whole of the virtual environment being used. In such cases, memory usage information must be estimated from the control panel, or the /proc/user_beancounters file.