"ps -o rss,drs,trs,vsz,sz" - Process Status Options

This section provides a tutorial on how to 'ps -o rss,drs,trs,vsz,sz' command to report memory usage of each running process.

If you want to know memory usage at the process level, you can use the "ps -o" command option with "rss,drs,trs,vsz,sz" output fields. Here are some examples:

1. The following command displays all running processes with memory usage fields:

herong$ ps -e -o pid,euser,%cpu,%mem,rss,drs,trs,sz,vsz,comm

 PID EUSER %CPU %MEM  RSS    DRS TRS    SZ    VSZ COMMAND
   1 root   0.0  0.0 7376 241488   0 60372 241488 systemd
   2 root   0.0  0.0    0      0   0     0      0 kthreadd
   3 root   0.0  0.0    0      0   0     0      0 rcu_gp
   4 root   0.0  0.0    0      0   0     0      0 rcu_par_gp
...
1515 root   0.0  0.0  480  50400   0 12600  50400 smartd
1520 root   0.0  0.0  480 219444   0 54861 219444 sssd
1521 rtkit  0.0  0.0   28 202848   0 50712 202848 rtkit-daemon
1522 dbus   0.0  0.0 3228  93028   0 23257  93028 dbus-daemon
...

The memory usage fields in the output are:

2. The "--sort=vsz" option sorts the output by the virtual memory usage.

herong$ ps -e -o pid,euser,%mem,rss,drs,trs,sz,vsz,comm --sort=vsz

  PID EUSER  %MEM  RSS   DRS  TRS   SZ   VSZ COMMAND
    2 root    0.0    0     0    0    0     0 kthreadd
    3 root    0.0    0     0    0    0     0 rcu_gp
    4 root    0.0    0     0    0    0     0 rcu_par_gp
    8 root    0.0    0     0    0    0     0 mm_percpu_wq
...
58989 herong  0.0 2232  9731   36 2442  9768 more
 1532 root    0.0    4 17788    0 4447 17788 mcelog
58491 herong  0.0 5332 24853 1054 6477 25908 bash
 1559 root    0.0 1592 26836    0 6709 26836 ksmtuned
...

3. The "--sort=-vsz" option sorts the output by the virtual memory usage in descending order.

herong$ ps -e -o pid,euser,%mem,rss,drs,trs,sz,vsz,comm --sort=-vsz

  PID EUSER   %MEM    RSS     DRS TRS      SZ     VSZ COMMAND
 3399 gdm      0.3  55744 8618344   0 2154586 8618344 gnome-shell
 1998 mysql    4.1 645924 3439668   0  859917 3439668 mysqld
 2498 gdm      0.0   7476 3089652   0  772413 3089652 Xorg
91677 apache   0.1  16856 2801800   0  700450 2801800 httpd
92412 apache   0.0  14176 2605120   0  651280 2605120 httpd
 1517 polkitd  0.0   2552 2064372   0  516093 2064372 polkitd
...

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

Memory Management

 Layers of Memory and Access Speed

 List CPU Caches and Their Sizes

 Virtual Memory vs. Physical Memory

 Buffer Memory and Cache Memory

 Verify Cache Memory with "cp" Command

 What Is Swap Space

 Virtual Memory Mapping and Page Table

"ps -o rss,drs,trs,vsz,sz" - Process Status Options

 smem - Process Memory Usage Report

 pmap - Process Memory Map

 /proc/{id}/maps - Process Memory Map

 /proc/{id}/smaps - Process Memory Map Details

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB