procs Is A Modern Replacement For ps With Colored Output, Additional Information (Written In Rust)

procs ps alternative in rust

procs is a modern replacement for ps written in Rust. Compared to ps, it comes with colored and human-readable output, additional information like TCP/UDP port, read/write throughput, more memory information and Docker container name, and more.

The tool runs on Linux, and there’s also experimental support for macOS and Windows, although some information is not available on these. Also, the pager is not supported on Windows.

procs features include:

  • Colored, human-readable output format with automatic theme detection based on the terminal background
  • Keyword search over multi-column
  • Pager support
  • Watch mode like top (--watch or --watch-interval <seconds>, which has some additional keyboard shortcuts (n to change sort column to next, p to change sort to previous column, a changes the sort order to ascending, d changes the sort to descending, and q quits)
  • Tree view (--tree)
  • Can display information not supported by ps, like:
    • TCP/UDP ports
    • Read/write throughput
    • Docker container name
    • More memory information

By default, procs only shows the PID, User, TTY, CPU, MEM, CPU Time, and Command columns, but you can add various other types of information. 

You can find a list with the type of information that procs can display, as well as a comparison with ps, and the procs information types that are or aren’t available on macOS and Windows, here.

You might also like: Easily Load, Unload And Blacklist Kernel Modules With kmon (TUI)

Install procs

There are procs packages for many Linux distributions, including Alpine Linux, Arch Linux and Fedora, as well as generic Snap packages. You may also install the tool using cargo. On macOS, procs can be installed from homebrew.

You’ll also find precompiled binaries on the project releases page, for Linux (generic binary and RPM), macOS and Windows (x86_64 only for all platforms).

You can install the generic Linux binary (the -lnx.zip package) by extracting it, then open a terminal and navigate to the folder where you’ve extracted the ZIP archive, and install it using:

sudo install procs /usr/local/bin

You might also like: Zellij Is A New Terminal Multiplexer Written In Rust

Basic usage

To use procs, run the executable, and it will show information about all the running processes:

procs

Pass a non-numeric keyword as an argument, and procs will search this keyword and match it to USER, Command by default (for non-numeric keywords, this is treated as a partial match by default). E.g.:

procs firefox

This is a screenshot of the output:

procs search name

By passing a numeric keyword as an argument, procs matches it to PID by default, treating it as an exact match. E.g.:

procs 6171

This is a screenshot of this command’s output:

procs pid

When searching, you can use logical operators like -a, --and, -o, --or, -d, --nand, and -r, --nor.

Configuration

You can configure procs either by using command line flags (see procs --help), or using its configuration file. You can generate a sample configuration file by using:

procs --config

Copy this command’s output starting with [[columns]] all the way down, then create the procs configuration file on Linux using:

mkdir -p ~/.config/procs/config.toml
touch ~/.config/procs/config.toml

Now open ~/.config/procs/config.toml with a text editor of your choice, and paste the procs --config output (from [[columns]] to the bottom of the command output). Save the file when you’re done.

With the basic configuration in place, configuring procs to your liking should be easy. For example, let’s add 2 new columns for displaying information about TCP and UDP ports. Copy the following configuration:

[[columns]]
kind = "TcpPort"
style = "BrightYellow|Yellow"
numeric_search = false
nonnumeric_search = true
align = "Left"

[[columns]]
kind = "UdpPort"
style = "BrightYellow|Yellow"
numeric_search = false
nonnumeric_search = true
align = "Left"

And paste it in the ~/.config/procs/config.toml file, somewhere between the other [[columns]], where you want the TCP and UDP columns to be displayed. You can also add a separator before and after these 2 TCP and UDP columns:

[[columns]]
kind = "Separator"
style = "White|BrightBlack"
numeric_search = false
nonnumeric_search = false
align = "Left"

When you’re done, save the file and run procs. You should see 2 new columns showing TCP and UDP ports. For example, here are the ports used by qBittorrent on my computer, using this configuration:

procs tcp udp

In the same way you can add many other column types. E.g. to add Docker container names, add “Docker” as the column kind. You can find many other types of columns (refered to as “kind” in the procs documentation) that you can add. See a complete list here.

In the procs configuration file you can also specify the colors to be used, style, set numeric and nonnumeric searches to exact or partial, set the default column to sort by and if it should be sorted ascending or descending, and more.

You might also like: s-tui: CPU Monitoring And Stress Testing Console UI Tool

Posted by WordPress Guru