Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of five commands for Linux to check Swap swap space

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

Two types of swap space can be created under Linux, one is the swap partition, and the other is the swap file. The former is suitable for free partitions to use, while the latter is suitable for no free hard disk partitions, and the hard disk space has been allocated. For example: when installing redhat, you can allocate hard disk space by default, switch the size of the system default configuration, when you need to install an oracle database after you install the system, suddenly warn that there is not enough swap space. What should we do now?

When the physical memory or RAM on our system is full, we will eventually take advantage of the swap space on the system. During this process, inactive pages of memory are moved to swap space, creating more memory resources. This space is particularly useful when the system shuts down RAM; however, the swap space is on the hard drive, so access is slow. Therefore, it should not be seen as an appropriate alternative to RAM.

In this article, we will introduce several ways to check the available Swap swap space on Ubuntu systems. The commands and procedures described in this article have been run on a Ubuntu 18.04 LTS system.

We are using the Ubuntu command line terminal to check the swap space on our system. To open the terminal, you can use the Dash or Ctrl + alt + T shortcut keys. You can then choose the following ways to obtain exchange space information:

Linux free command

Command:

Free

This command is used to check memory and swap utilization on the system in several lines. Without using any switches, the displayed output is printed in kilobytes.

Use the free command to check swap space

Command:

Free-h

Using the-h switch, the free command displays memory and swap utilization in the nearest 3-digit format.

Free-h command

Swapon command

Command:

$swapon-s

You can use the swapon command to check the exchange of specific partitions, logical volumes, or files. Here, we will use the-s (summary) switch to get the exchange details in kilobytes.

Swapon command

Top command

Command:

$top

The title section of the output of the top command displays swap space information in kilobytes. Other commands that provide this information include htop,glances, itop, and so on.

Use the top command to check swap usage

Vmstat command

Command:

$vmstat

With the vmstat command, you can view the exchange and exchange information. However, you cannot see the total value of the exchange, as shown in the previously mentioned command.

Use the vmstat command to check swap space

/ proc/swaps file

Command:

$cat / proc/swaps

You can also view the exchange size information through the exchange configuration file / proc/swaps. It also displays the exchange information of the device so that you can view the device name (partition, logical volume, or file), its type, and the amount of exchange it provides to the system.

Check the contents of / proc/swaps

Although very simple commands are described in this article, you can view the swap space on the Ubuntu system and use it when the system runs out of RAM resources.

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report