• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Check Swap Usage Live via the ‘top’ Command in Linux

by admin

Question: How to view the system-wide swap usage on a CentOS/RHEL server via the top command to identify the highest consumers.

Below are the steps for CentOS/RHEL 5 and 6 which are the same, followed by CentOS/RHEL 7 as they differ on this release:

NOTE: Performing this task will not cause any changes to top command, this is only temporary while you have your top command running. Exiting top and starting it again will reset your changes.

For CentOS/RHEL 5 and 6

1. Run the TOP command:

# top

2. On your keyboard press the “f” key followed by “p” to add the Swap column, Hit enter.

check live swap usage in CentOS RHEL 6

3. Next, upper case “O” and finally “p” sort by swap, Hit enter.

live swap usage in Linux using top command

4. Perform your review as needed and press “q” to exit top command.

swap usage live on CentOS RHEL

For CentOS/RHEL 7

1. Run the TOP command:

# top

2. On your keyboard press the “f” key and scroll down using the [down] arrow key until you have selected “SWAP” then press [Space] to select it. This should add a “*” symbol in front of it.

swap utilization live view in CentOS and RHEL 7

3. While still selecting “SWAP” press the [right] arrow key, which highlights the entire SWAP line, and using the [top] arrow key move it up to one of the first options (anywhere above “COMMAND”).

check swap utilization using top

4. While still having “SWAP” selected, type the “s” key which will configure top to SORT by the currently selected option, in this case, SWAP. You will not see any changes on the screen when you press “s”, but the setting is saved in the backend.

5. Finally “q” to save the configuration changes and view the results.

check swap usage live in Linux

6. Perform your review as needed and press “q” again to exit top command.

For more information on top options and fields review the man page. Below are a few lines from the top man page that provide some information on the memory fields and what they represent.

# man top
MEM -- Memory Usage (RES)
A task's currently used share of available physical memory.

RES -- Resident Memory Size (KiB)
The non-swapped physical memory a task is using.

SHR -- Shared Memory Size (KiB)
The amount of shared memory available to a task, not all of which is typically resident. It simply reflects memory that could be potentially shared
with other processes.

SWAP -- Swapped Size (KiB)
The non-resident portion of a task's address space.

VIRT -- Virtual Memory Size (KiB)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages
that have been mapped but not used.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. amixer Command Examples in Linux
  2. CentOS / RHEL : How to block incoming and outgoing ports using iptables
  3. How to Create An LVM Snapshot Of The Root Filesystem And Restore To An Earlier State
  4. How to find the inode size of an ext2/ext3/ext4 filesystem?
  5. Ubuntu Linux – yED(Graph Editor) Alternate of Microsoft Office Visio
  6. Supported and Recommended File Systems on Linux
  7. How To Configure Timeout On SSH Client Putty
  8. Understanding Variables in Bash Shell Under Linux
  9. make Command Examples in Linux
  10. qtchooser: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright