procinfo Command in Linux

Introduction

In this tutorial, we will delve into the Linux procinfo command, a valuable tool for system monitoring and diagnostics. This guide covers the fundamentals of the procinfo command, focusing on how to use it to monitor critical system metrics such as CPU utilization, memory consumption, disk I/O, and network activity. You'll also discover how to tailor the procinfo output to display only the system information you need. This tutorial aims to provide practical skills in system monitoring and management using the procinfo utility.

Please note that the procinfo command might not be pre-installed on all Linux distributions. You may need to install the procinfo package using your distribution's package manager. Also, be aware that procinfo is considered a legacy tool, and might not be present in newer Linux versions. In such cases, consider modern alternatives like htop or top for comprehensive system monitoring.

Introduction to procinfo Command

In this section, we will introduce the procinfo command, a useful tool for observing system information on Linux. The procinfo command gives you a detailed view of system parameters, including CPU, memory, disk, and network utilization.

First, let's install the procinfo package on our Ubuntu 22.04 Docker container:

sudo apt-get update
sudo apt-get install -y procinfo

Now, let's execute the procinfo command to view the default system information report:

sudo procinfo

Example output:

Linux 5.15.0-1025-aws (ubuntu) 	22.04.1 LTS 	2023-03-28 	_x86_64_

CPU:
  CPU0: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
  CPU1: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
  Frequency (MHz): 2600.000
  Load average: 0.00 0.01 0.00

Memory:
  Total: 1024 MB
  Free: 583 MB
  Buffers: 31 MB
  Cached: 279 MB

Swap:
  Total: 0 MB
  Free: 0 MB

Uptime: 0 days, 0:00

Disk:
  /dev/vda1 (ext4): 8.0 GB, 8000000000 bytes
  Inodes: 2097152, Used: 23781

Network:
  eth0: RX: 0 packets, 0 bytes | TX: 0 packets, 0 bytes

The procinfo command delivers a wealth of insights into your system, providing details on CPU, memory, swap space, system uptime, disk usage, and network traffic. This information can be invaluable for monitoring system performance and performing root cause analysis.

In the following section, we will learn how to customize the procinfo command's output to focus on specific metrics.

Monitoring System Information with procinfo

In this step, we will learn how to use the procinfo command to monitor particular areas of your system.

The procinfo command gives you many options to customize the display. Let's explore some of the more useful options:

  1. Display CPU information:
sudo procinfo -C

Example output:

CPU:
  CPU0: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
  CPU1: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
  Frequency (MHz): 2600.000
  Load average: 0.00 0.01 0.00
  1. Display memory information:
sudo procinfo -M

Example output:

Memory:
  Total: 1024 MB
  Free: 583 MB
  Buffers: 31 MB
  Cached: 279 MB
  1. Display disk information:
sudo procinfo -D

Example output:

Disk:
  /dev/vda1 (ext4): 8.0 GB, 8000000000 bytes
  Inodes: 2097152, Used: 23781
  1. Display network information:
sudo procinfo -N

Example output:

Network:
  eth0: RX: 0 packets, 0 bytes | TX: 0 packets, 0 bytes

You can also combine these options to view multiple aspects of your system at once. For example:

sudo procinfo -CMN

This command will display CPU, memory, and network data in a single output.

The procinfo command is very versatile, enabling you to customize its output to fit your needs. In the next step, we will explore how to further customize the procinfo output.

Customizing procinfo Output

In this final part, we will discover how to configure the output of the procinfo command to focus on specific system details.

The procinfo command enables you to choose what system information is displayed by using command-line switches. Let's review a few examples:

  1. Display only CPU information:
sudo procinfo -C
  1. Display only memory information:
sudo procinfo -M
  1. Display only disk information:
sudo procinfo -D
  1. Display only network information:
sudo procinfo -N

You can also combine options to show multiple types of system stats simultaneously. For example:

sudo procinfo -CM

This command will show CPU and memory data together.

In addition, you can save the procinfo command's output to a file for later examination:

sudo procinfo -CMN > system_info.txt

This will save the CPU, memory, and network information to a file called system_info.txt in the current directory.

The procinfo command can also format the output. You can use the -f option followed by a format string to customize the output. For instance:

sudo procinfo -f "CPU: %c, Memory: %m, Disk: %d, Network: %n"

This will display the system information in a more compact and custom format.

By using the many options and features of the procinfo command, you can customize the output to present the system information that is most valuable to your monitoring and troubleshooting processes. A systemadmin can use this to create custom monitoring scripts.

Summary

In this tutorial, we investigated the useful procinfo command in Linux, a tool that provides a comprehensive picture of system parameters. We began by installing the procinfo package and executing the command to view the default system information, including CPU, memory, swap, uptime, disk, and network metrics. We then learned to customize the procinfo output to concentrate on specific data, such as CPU details, memory usage, and disk statistics. This practical experience with the procinfo command can be helpful for monitoring system health and resolving issues on Linux systems. This is a valuable tool for any systemadmin.

400+ Linux Commands