Home Command line utilities How To Display Process Information Using Procs On Linux

How To Display Process Information Using Procs On Linux

Procs - A modern replacement for ps written in Rust

By sk
Published: Last Updated on 4K views

In this tutorial, we will discuss what is Procs, how to install Procs in Linux, and how to display process information using Procs on Linux.

What is Procs?

Procs is a command line utility to show information about active and running processes. It is just like the traditional Ps command but with some extra features. The developer says Procs is a modern replacement for Ps command.

Procs is cross-platform application written in Rust programming language. As of writing this guide, Procs fully supports Linux. Mac OS and Windows are experimentally-supported.

Features

Compared to Ps, the Procs has a few advantages as listed below.

  • It displays the output in colored format.
  • Displays output in human-readable format.
  • Displays additional information which are not supported by ps.
    • TCP/UDP port
    • Read/Write throughput
    • Docker container name
    • More memory information
  • Displays processes in tree-like view.
  • Pager support.

Install Procs in Linux

There are couple ways to install Procs on Linux. Pick one that suits to you.

Download Procs binary:

Download latest Procs binary file from releases page.

$ wget https://github.com/dalance/procs/releases/download/v0.13.3/procs-v0.13.3-x86_64-linux.zip

Extract the downloaded zip file:

$ unzip procs-v0.13.3-x86_64-linux.zip

Move it to your $PATH, for example /usr/local/bin/:

$ sudo mv procs /usr/local/bin/

Finally, make it executable:

$ sudo chmod +x /usr/local/bin/procs

Using Cargo:

Since Procs is written in Rust, we can install it using Cargo package manager. TO use Cargo package manager, install Rust in Linux as described in the following link.

After installing Rust, run the following command to install Procs:

$ cargo install procs

Using Snap:

$ sudo snap install procs

Using Nix package manager:

$ nix-env --install procs

Using Linuxbrew:

$ brew install procs

After installing Procs, you need to do the following things to make it work properly.

On some environments, the UTF-8 characters will look like as weird escaped characters like below.

Odd escaped characters in Procs output

Odd escaped characters in Procs output

To fix this issue, add the following environment variable in ~/.bashrc or ~/.bash_profile or ~/.profile files:

export LESSCHARSET=utf-8

The normal user can't access some information (ex. Read/Write throughput) of other users using Procs on Linux. To enable normal users to access these information, run:

$ procs --suid
sudo sh -c "chown root /usr/local/bin/procs; chmod u+s /usr/local/bin/procs"

All done! It is time to see how to use Procs to view information about processes.

Display Process Information Using Procs On Linux

Procs usage is almost same as ps command. Allow me to show you a few examples.

View information about all processes

To show information about all running processes on your Linux box, simply run:

$ procs

Sample output:

Display Process Information Using Procs On Linux

Display Process Information Using Procs On Linux

As you can see, Procs displays detailed information about all processes. This is equivalent to "ps aux" command, however the output is better compared to Ps output and has some additional information such as TCP/UDP port number, Read/Write throughput, and color support etc. To quit Procs, press q or CTRL+c.

Procs will show the output in one page at a time. If output lines exceed terminal height, pager is used automatically. You can view the rest of the output by pressing the ENTER key. UP/DOWN arrows can be used to go previous or next pages.

Display processes matching to a string

Procs can able to display processes matching to a specific keyword.

The following command displays processes matches with keyword "sshd".

$ procs sshd

Similarly, we can display information of processes matches with string sk.

$ procs sk

Sample output:

Display processes matching to a string

Display processes matching to a string

Please note that it will display all processes that contains the given string. It is not specific to a USER or COMMAND.

Display processes matching to a number

It is also possible to display process information matching to numeric keywords like PID, TCP, UDP. For instance, the following command displays processes details matching to number 22:

$ procs 22
 PID:▲ User │ State Nice TTY CPU MEM  VmPeak  VmSize   VmRSS TCP  UDP  Read Write │ CPU Time Start            │ Command          
            │                [%] [%] [bytes] [bytes] [bytes]          [B/s] [B/s] │                           │                  
 22    root │ S       19     0.0 0.0               0       0 []   []      0     0 │ 00:00:00 2020/01/08 12:02 │ khugepaged       
 1030  root │ S        0     0.0 0.3 70.629M 70.602M  5.625M [22] []      0     0 │ 00:00:00 2020/01/08 12:03 │ /usr/sbin/sshd -D

As you see in the above output, the number 22 is present in PID and TCP columns.

Display processes in tree-like view

To display information about all processes in tree-like format, run:

$ procs -t

Or,

$ procs --tree
Display processes in tree-like view using proc

Display processes in tree-like view using proc

All processes are sorted by dependency order and dependency tree is shown at left side.

Ps command also displays process information in tree format using command:

$ ps axjf

Or,

$ ps -ejH

However, Procs tree format is aligned better than ps command's output.

Change column sort order

Procs allows you to change the order of user, state, Nice value, cpu time, vmsize, vmrss, read/write throughput columns as you wish. You can short the columns result in ascending or descending order.

For example, to sort the order of cpu time column in ascending order, use sorta (sort ascending) option like below:

$ procs --sorta cpu

Similarly, to sort in descending order, use sortd (sort descending) option:

$ procs --sortd cpu

Watch mode

Procs supports watch mode, just like top command. You should have noticed that the output of Top command updates automatically at 3.0 seconds interval by default. Procs can also updates its output automatically by user-specified intervals. For example, to update output of Procs every 2 seconds, run:

$ procs --watch 2

To quit watch mode, press q or Ctrl+c.


Suggested read:


More details can be found in the help section.

$ procs --help
procs 0.8.16

USAGE:
    procs [FLAGS] [OPTIONS] [--] [KEYWORD]...

FLAGS:
    -a, --and        AND  logic for multi-keyword
    -o, --or         OR   logic for multi-keyword
    -d, --nand       NAND logic for multi-keyword
    -r, --nor        NOR  logic for multi-keyword
    -l, --list       Show list of kind
    -t, --tree       Tree view
        --config     Generate configuration sample file
        --suid       Set suid bit and change binary owner to root
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -w, --watch <second>         Watch mode
    -i, --insert <kind>...       Insert column to slot
        --sorta <kind>           Sort column by ascending
        --sortd <kind>           Sort column by descending
    -c, --color <color>          Color mode [possible values: auto, always, disable]
    -p, --pager <pager>          Pager mode [possible values: auto, always, disable]
        --interval <millisec>    Interval to calculate throughput [default: 100]

ARGS:
    <KEYWORD>...    Keywords for search

What do you think about this utility? Tell us about your thoughts in the comment section below.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More