Linux is not like Windows and you will not get a GUI always, especially in a server environment.
As a Linux administrator, it is important to know how to check your available and used resources, such as memory, CPU, disk space, etc.
If there are any applications that use too much resources on the system to run your system at the optimum level you need to find and fix.
If you want to **[find out the top 10 memory (RAM) consumption processes in Linux][1]**, go to the following article.
In Linux, there are commands for everything, so use the corresponding commands.
In this tutorial, we will show you eight powerful commands to check memory usage on a Linux system, including RAM and swap.
**[Creating swap space on a Linux system][2]** is very important.
The following commands can help you check memory usage in Linux in different ways.
* free Command
* /proc/meminfo File
* vmstat Command
* ps_mem Command
* smem Command
* top Command
* htop Command
* glances Command
### 1) How to Check Memory Usage on Linux Using the free Command
**[Free command][3]** is the most powerful command widely used by the Linux administrator. But it provides very little information compared to the “/proc/meminfo” file.
Free command displays the total amount of free and used physical and swap memory on the system, as well as buffers and caches used by the kernel.
These information is gathered from the “/proc/meminfo” file.
```
# free -m
total used free shared buff/cache available
Mem: 15867 9199 1702 3315 4965 3039
Swap: 17454 666 16788
```
* **total:** Total installed memory
* **used:** Memory is currently in use by running processes (used= total – free – buff/cache)
* **free:** Unused memory (free= total – used – buff/cache)
* **shared:** Memory shared between two or more processes (multiple processes)
* **buffers:** Memory reserved by the kernel to hold a process queue request.
* **cache:** Size of the page cache that holds recently used files in RAM
* **buff/cache:** Buffers + Cache
* **available:** Estimation of how much memory is available for starting new applications, without swapping.
### 2) How to Check Memory Usage on Linux Using the /proc/meminfo File
The “/proc/meminfo” file is a virtual file that contains various real-time information about memory usage.
It shows memory stats in kilobytes, most of which are somewhat difficult to understand.
However it contains useful information about memory usage.
```
# cat /proc/meminfo
MemTotal: 16248572 kB
MemFree: 1764576 kB
MemAvailable: 3136604 kB
Buffers: 234132 kB
Cached: 4731288 kB
SwapCached: 28516 kB
Active: 9004412 kB
Inactive: 3552416 kB
Active(anon): 8094128 kB
Inactive(anon): 2896064 kB
Active(file): 910284 kB
Inactive(file): 656352 kB
Unevictable: 80 kB
Mlocked: 80 kB
SwapTotal: 17873388 kB
SwapFree: 17191328 kB
Dirty: 252 kB
Writeback: 0 kB
AnonPages: 7566736 kB
Mapped: 3692368 kB
Shmem: 3398784 kB
Slab: 278976 kB
SReclaimable: 125480 kB
SUnreclaim: 153496 kB
KernelStack: 23936 kB
PageTables: 73880 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 25997672 kB
Committed_AS: 24816804 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Percpu: 3392 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 1059088 kB
DirectMap2M: 14493696 kB
DirectMap1G: 2097152 kB
```
### 3) How to Check Memory Usage on Linux Using the vmstat Command
The **[vmstat command][4]** is another useful tool for reporting virtual memory statistics.
vmstat reports information about processes, memory, paging, block IO, traps, disks, and cpu functionality.
vmstat does not require special permissions, and it can help identify system bottlenecks.
### 5) How to Check Memory Usage on Linux Using the smem Command
**[smem][6]** is a tool that can provide numerous reports of memory usage on Linux systems. Unlike existing tools, smem can report Proportional Set Size (PSS), Unique Set Size (USS) and Resident Set Size (RSS).
Proportional Set Size (PSS): refers to the amount of memory used by libraries and applications in the virtual memory system.
Unique Set Size (USS) : Unshared memory is reported as USS (Unique Set Size).
Resident Set Size (RSS) : The standard measure of physical memory (it typically shared among multiple applications) usage known as resident set size (RSS) will significantly overestimate memory usage.
### 6) How to Check Memory Usage on Linux Using the top Command
**[top command][7]** is one of the most frequently used commands by Linux administrators to understand and view the resource usage for a process on a Linux system.
It displays the total memory of the system, current memory usage, free memory and total memory used by the buffers.
In addition, it displays total swap memory, current swap usage, free swap memory, and total cached memory by the system.
```
# top -b | head -10
top - 11:04:39 up 40 min, 1 user, load average: 1.59, 1.42, 1.28
### 7) How to Check Memory Usage on Linux Using the htop Command
The **[htop command][8]** is an interactive process viewer for Linux/Unix systems. It is a text-mode application and requires the ncurses library, it was developed by Hisham.
It is designed as an alternative to the top command.
This is similar to the top command, but allows you to scroll vertically and horizontally to see all the processes running the system.
htop comes with Visual Colors, which have added benefits and are very evident when it comes to tracking system performance.
You are free to carry out any tasks related to processes, such as process killing and renicing without entering their PIDs.
[![][9]][10]
### 8) How to Check Memory Usage on Linux Using the glances Command
**[Glances][11]** is a cross-platform system monitoring tool written in Python.
You can see all information in one place such as CPU usage, Memory usage, running process, Network interface, Disk I/O, Raid, Sensors, Filesystem info, Docker, System info, Uptime, etc,.