There are several methods in Linux or Unix machines to determine how much RAM or memory you have installed on your machine. Though most of these commands are available across different and all Posix platforms, some are also dependent on the Linux distributions and what libraries you have installed.
The easiest way to find out as to how much memory is installed on your system is to use the command shell. There are also a couple of GUI options depending on your distro. Most people might find the GUI based option much more user friendly to use.
You can use the free command to find almost all information about the RAM or memory usage and availability. There are several command line options available with the command to print the information in bytes, kilobytes, megabytes or gigabytes. –human (or -h) will print the output in human readable format, while –total (or -t) will add a row which totals the columns.
bash$ free -ht
There is also the option to print out the lowest and highest memory usage statistics using -l.
bash$ free -htl
Another way to find the available memory is using the top command. Though primarily used to display process information, it also displays some information about the installed RAM (random access memory) or the memory. Look for information at the top of the output, where it says KiB Mem which displays the total available memory on the system.
Another option is to check the kernel ring buffer output to see what the kernel detected during the system startup about the installed memory. This information is printed out with a line prefix Memory. So, the following command will print out the memory information…
bash$ dmesg | grep Memory
will output something like
Memory: 6156316k/7012352k available (4648k kernel code, 63836k reserved, 2402k data, 424k init, 5307208k highmem)
The first part of the output is the value that you are looking for.
Apart from the free and top command, most modern Linux distros also have a GUI option which shows the entire system information including the installed memory.
In Gnome, gnome-system-monitor will show you the memory usage and the total memory installed on the system. You can access this from a terminal by the command gnome-system-monitor or access it from the menu, look for a menu entry by the name of System Monitor.
In KDE, the equivalent GUI option is ksysguard. Again you can access it by the command ksysguard at the command prompt or look for it in the KDE menu by the name of System Monitor.
Though all the above commands and programs will give you a somewhat detailed information about the memory status on your system, that is not all you can find. You can find a plethora of information about your installed memory from the process file meminfo. If you are just looking to find the total memory installed on your system, then this might actually be an overkill.
bash$ cat /proc/meminfo
As you can see there is lot of information in the output, actually way more than what the above screenshot shows. You can use the grep command to narrow the output down to the memtotal row, which shows you the total installed memory on your system.
bash$ grep -i memtotal /proc/meminfo
The above command will just print out the field MemTotal from the output, which is the total memory that is installed in the system. You can use the grep command to filter the output further to display just the required fields or lines.