Swap space (which is known as paging in Windows) is part of the hard disk but it used as RAM for faster processing. It is utilized when a physical RAM is full.

In this article, I am going to show you seven commands that can be used to check memory usage and swap space in Debian 10.

How to check memory usage and swap space usage in Debian 10

There are following six commands you can use to check the swap size in Debian 10.

  1. The free command
  2. The swapon command
  3. The top command
  4. The vmstat command
  5. The atop command
  6. The htop command
  7. The glances command

The free command

You can check the total, used and free swap space with the help of free command. The result will be displayed in kilobytes. The command looks like the following.

free

Check memory usage with free command

If you want to check the swap space in human-readable format with the closest possible unit, use the -h switch as follows.

free -h

Free command output in human readable format

The swapon command

You can use the swapon command to check the swap space on a particular partition, logical volume or a file. Here is the complete command.

swapon -s

Use swapon command to see swap usage

The top command

The top is a command which shows many parameters including the uptime, the number of users logged in, average load, the number of tasks running, sleeping or stopped, the number of zombie processes, CPU utilization, available/used physical memory and swap space.

Open up the terminal and execute the following.

top

The fifth header from the top will show you the stats about swap space.

Check swap usage with top command

The vmstat command

With the help of vmstat command, you can view the swap in and out information as shown in the following screenshot. The command should look like the following.

vmstat

Check swap with vmstat

The atop command

The atop command is just like a top command which also gives information about swap space.

If the command is not available on your system, execute the following on terminal with root privileges to install it.

apt-get install atop

Wait for the operation to complete.

Execute the following on a terminal.

atop

Use atop command to see swap usage

The fifth header shows the information about swap space as shown in the above screenshot.

The htop command

The Linux htop command is another useful command just like top and atop command. Along with other information, this can also show the swap space utilization.

If the command is not available on your system, execute the following on terminal with root privileges to install it.

apt-get install htop

Wait for the command to finish.

Execute the following on the terminal.

htop

The third column gives information about swap space as shown in the following screenshot.

Check swap usage with htop

The glances command

Glances is another pretty tool that can give you information about swap space utilization. If the tool is not available on your machine, execute the below command to install it. Make sure you have root privileges.

apt-get install glances

Once the tool has been installed, run the following command on the terminal.

glances

The fourth column shows the swap space utilization as shown in the following screenshot.

Check memory usage with Glances command

So the following were some of the commands you can use to check swap space in Linux and they should be helpful in troubleshooting the system. Good luck!!

7 Commands to Check Memory Usage and Swap Space in Debian 10