Home Command line utilities How To Display Process Information Using Procs On Linux
display process information using Procs on Linux from command line

How To Display Process Information Using Procs On Linux

By sk
382 Views

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. It is known as a modern replacement for Ps command. Procs is written in Rust programming language and it is cross-platform. As of writing this guide, Procs fully supports Linux. Mac OS and Windows are experimentally-supported. In this brief tutorial, let us see how to install Procs and how to display process information using Procs on Linux.

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

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.8.16/procs-v0.8.16-x86_64-lnx.zip

Extract the downloaded zip file:

$ unzip procs-v0.8.16-x86_64-lnx.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

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

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

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

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 decending 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 decending 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

Hope it helps.

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

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More