Exploring the /proc filesystem with Python and shell commands

/proc Talk

© Lead Image © Ioannis Kounadeas, Fotolia.com

© Lead Image © Ioannis Kounadeas, Fotolia.com

Article from Issue 217/2018
Author(s):

The Linux /proc virtual filesystem offers a window into a running system – look inside for information on processes and kernel activity.

The proc filesystem [1] (procfs for short), is a Linux pseudo-filesystem that provides an interface to the operating system's kernel data structures. Procfs leverages the well-known concept of "in Unix, everything is a file" [2] to provide the same uniform interface of Unix file I/O (e.g., open, read, write, close, etc.) for getting kernel- and OS-related information. This uniformity makes it easier for the Linux programmer or system administrator to learn about the kernel, with fewer interfaces to learn.

Procfs is usually mounted at /proc. Many kinds of information about the operating system (OS) and processes running in it are exposed via pseudo-files in procfs. By reading data from /proc files, you can learn a lot of useful information about the system.

This article shows some ways of getting information from procfs using custom Python programs and Linux commands.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line – Probing /proc

    The mysterious /proc virtual filesystem is a rich mine of information about everything in your system.

  • Go Programming

    The Go programming language combines type safety with manageable syntax and an extensive library. We take you through a programming example.

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • Hardware Detection

    If you need fast answers for what's inside, you can use a Bash script to obtain an inventory of hardware on your Linux system.

  • Udev

    After three years of hanging around on the sidelines, Udev has finally ousted the legacy Dev-FS system. We take a look under the hood at the Udev device management system inside your Linux system.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News