Linux procinfo Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux procinfo command, which is a powerful tool for monitoring system information. The lab covers the basics of the procinfo command, including how to monitor system information such as CPU, memory, disk, and network usage. Additionally, we will learn how to customize the procinfo output to focus on specific system information. This lab is designed to provide a practical understanding of system monitoring and management using the procinfo command.

The procinfo command is not installed by default on some Linux distributions, so you may need to install the procinfo package before using it. Additionally, the procinfo command is considered outdated and may not be available in newer Linux distributions, in which case you may want to consider using alternative tools like htop or top for system monitoring.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux(("`Linux`")) -.-> linux/InputandOutputRedirectionGroup(["`Input and Output Redirection`"]) linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/BasicFileOperationsGroup -.-> linux/cat("`File Concatenating`") linux/InputandOutputRedirectionGroup -.-> linux/redirect("`I/O Redirecting`") linux/PackagesandSoftwaresGroup -.-> linux/apt("`Package Handling`") linux/SystemInformationandMonitoringGroup -.-> linux/ps("`Process Displaying`") linux/SystemInformationandMonitoringGroup -.-> linux/top("`Task Displaying`") linux/SystemInformationandMonitoringGroup -.-> linux/free("`Memory Reporting`") subgraph Lab Skills linux/cat -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} linux/redirect -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} linux/apt -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} linux/ps -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} linux/top -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} linux/free -.-> lab-422865{{"`Linux procinfo Command with Practical Examples`"}} end

Introduction to procinfo Command

In this step, we will explore the procinfo command, which is a powerful tool for monitoring system information on Linux. The procinfo command provides a comprehensive overview of various system parameters, including CPU, memory, disk, and network usage.

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 run the procinfo command to see the default system information output:

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 provides a wealth of information about the system, including CPU, memory, swap, uptime, and disk and network usage. This information can be useful for monitoring system performance and troubleshooting issues.

In the next step, we will explore how to customize the procinfo output to focus on specific system information.

Monitoring System Information with procinfo

In this step, we will learn how to use the procinfo command to monitor specific system information.

The procinfo command provides a wide range of options to customize the output. Let's explore some of the most 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 display multiple types of system information at once. For example:

sudo procinfo -CMN

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

The procinfo command provides a lot of flexibility in customizing the output to suit your specific monitoring needs. In the next step, we will explore how to further customize the procinfo output.

Customizing procinfo Output

In this final step, we will learn how to customize the output of the procinfo command to focus on specific system information.

The procinfo command allows you to specify which system information to display by using command-line options. Let's explore some 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 these options to display multiple types of system information at once. For example:

sudo procinfo -CM

This command will display CPU and memory information in a single output.

Additionally, you can save the procinfo output to a file for later analysis:

sudo procinfo -CMN > system_info.txt

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

The procinfo command also supports custom formatting of the output. You can use the -f option followed by a format string to specify the desired output format. For example:

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

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

By leveraging the various options and customization features of the procinfo command, you can tailor the output to focus on the specific system information that is most relevant to your monitoring and troubleshooting needs.

Summary

In this lab, we explored the powerful procinfo command in Linux, which provides a comprehensive overview of various system parameters. We started by installing the procinfo package and running the command to see the default system information output, including CPU, memory, swap, uptime, disk, and network usage. We then learned how to customize the procinfo output to focus on specific system information, such as CPU details, memory usage, and disk statistics. This hands-on experience with the procinfo command can be valuable for monitoring system performance and troubleshooting issues on Linux systems.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like