Learn how to Use procfs to Get System Associated Info in Linux

Did you know that Linux has an additional filesystem called procfs? So, you can use it to your advantage.

If you look at the Linux filesystem, you might find a / proc Directory with a lot of strange numbers and other files in it. What does this directory do? It actually contains a lot of useful information about your Linux system and the processes that are running.

This article explains the proc file system in detail, along with a brief guide on how to get system-related information using procfs.

What is the proc filesystem?

The proc file system (procfs) is an idea borrowed from the Plan 9 research system from Bell Labs, a research successor to the original Unix system developed there.

The file system extends the original concept of "everything as a file", including hardware devices, to its logical conclusion by representing every process running on the system as a hierarchy of files that you can examine with standard tools.

The most useful file in the process hierarchy for system information is the cpuinfo File. Enter the following to view it:

Cat / proc / cpuinfo

Depending on how many CPU cores your computer has, this file can contain a lot of information. So you should replace Most, a Linux pager, with cat.

Other useful files in / proc Directory are meminfo, which shows details about your system memory, and the connections File that provides information about the mounted file system. You can easily examine these files using standard Linux word processing tools.

Related: Best Command Line Utilities for Viewing File Contents in Linux

In the proc file system, all running processes have their own directory, which is their process ID number or PID. Process 1, the init process that starts all other processes on the Linux system when it boots, for example, has its own directory with the same number, / proc / 1.

While finding the process you want to investigate, use the ps, top, htop, or other Linux commands to list the PID of that particular process. When you find the process ID, navigate to that directory under / proc.

In the process directory you will find several files that contain information on various aspects of the process. For example, exe is a symbolic link to the executable that started the process, Surroundings lists environment variables and Command line displays all command line arguments used to start the process. The status File lists much of this information in a more human-readable format.

Related: What is a Process in Linux?

Get system information using procfs

The proc filesystem shows that pretty much everything is a file on Linux, even things you wouldn't expect. Even in the root folder, you can find many files, each of which contains information about various components of the system.

Linux, with its unique commands and myriad distributions, may seem like a mysterious operating system to beginners, but everything is in its right place.

Why are Linux commands so short? The history of Linux commands

Have you ever wondered why Linux commands are so short and strange? Teletypewriters and Unix is ​​the answer.

Continue reading

About the author

David Delony
(35 published articles)

David is a freelance writer living in the Pacific Northwest but originally from the Bay Area. He has been passionate about technology since childhood. David's interests include reading, watching quality TV shows and movies, retro games, and collecting records.

More
By David Delony

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email you just sent.

Leave a Reply

Your email address will not be published. Required fields are marked *