Swap space is a virtual memory that is used as a main memory when the main memory is fully occupied. Swap space is the part of secondary memory. It is very useful for systems that have limited main memory space. Ubuntu 22.04 specifies the swap space at the time of installation. You can check the amount of swap space by using different methods.

In this particular article, we will see these methods that how you can check the swap space in Ubuntu 22.04.

How to Check Swap Space in Ubuntu 22.04 using the “top” Command?

In Ubuntu 22.04, the swap space is automatically assigned during the installation process. You can check the amount of swap space by using different commands and methods. In this section, we will learn about these methods. Now take a look at these methods and use them to check the swap space.

Method 1: Using the System Monitor Tool

If you want to use GUI for checking the swap space then you can use the “System Monitor Tool”. This software is used to monitor the resources of the system in Ubuntu 22.04. Follow these steps to determine swap space:

  • Navigate to the Ubuntu desktop, click on the “Show Applications” menu button
  • From the applications window select and open the System Monitor tool
  • Now the System Monitor will be displayed
  • Select and click on the Resources tab from the top nav-bar
  • The following window will be displayed
  • The total swap space and used swap space will be displayed
  • In my system, the total swap space is 2.2 GB and 4.5 MB is being used

This is how you can check the swap space using the “System Monitor” tool.

Method 2: Using the “top” Command

The top command is used to list all the processes that are running in the system. It is used to display a table of processes along with the usage of different resources. You can use the “top” command to determine the swap space. It will display the total amount of swap space, the used swap space, and the available swap space. Use the following command syntax to execute the command:

$  top

The command will display the following output:

Method 3: Using the “atop” Command

The “atop” command is the advanced version of the “top” command. It is also used to monitor the usage of system resources. You can use the following command to check the swap space:

$ atop

The following output will be displayed in the terminal:

The output shows the number of CPUs, memory space, and swap space with their usage. 

Method 4: Using the “htop” Command

The “htop” command is also an alternative version of the “top” command. The “htop” command provides the real-time system resources stats. You can also use this command to check the amount of swap space. Type the “htop” in the terminal to determine the swap space:

$ htop

The command will display the stats shown in the diagram below:

This is how you can check the swap space by using the “System Monitor” tool, the “top” command, and the variants of the “top” command.

Conclusion

To check swap space in Ubuntu 22.04, you can use “System Monitor”, the “top” command, the “atop” command, and the “htop” command.  These commands also help a user, monitor the system resources. In this article, we have explained how you can check the swap space using the different commands and the “System Monitor” tool.