Kahibaro
Discord Login Register

1.5.2.6 `/proc`

What `/proc` Is

/proc is a virtual filesystem that exposes information about the running system and processes as if it were a set of files and directories.

Key characteristics:

On most systems, /proc is mounted as a proc filesystem:

mount | grep " on /proc "

Structure of `/proc`

Per-process directories

For every running process, there is a directory in /proc named with its PID (process ID):

Inside each PID directory, you’ll find files and subdirectories describing that specific process. Some useful ones:

This per-process tree lets you inspect what’s going on with any process without root in many cases (unless the process is owned by another user, in which case access may be restricted).

System-wide information in `/proc`

Besides per-PID directories, /proc contains many system-level pseudo-files.

Common ones you might use as a beginner:

  cat /proc/cpuinfo

These files are often read-only from the user’s perspective. Tools like free, top, uptime, and lsblk often use this data internally rather than querying hardware directly.

Kernel and System Settings in `/proc/sys`

The /proc/sys subtree exposes tunable kernel parameters. Many can be:

Parameters are grouped in directories by subsystem. Examples:

Individual examples (for illustration; do not change them on a production system without understanding them):

You can view a setting with:

cat /proc/sys/kernel/hostname

Many of these correspond to sysctl keys. For example:

Changing via file (temporary until reboot):

# Example: temporarily change swappiness (requires root)
echo 10 | sudo tee /proc/sys/vm/swappiness

Changing via sysctl (also temporary unless configured in a sysctl config file):

sudo sysctl vm.swappiness=10

Working With `/proc` Safely

Viewing `/proc` entries

You generally use the same tools as for normal text files:

Some caveats:

Permissions and security

For learning purposes on a personal system or virtual machine, you can:

Why `/proc` Matters

For a beginner, the main ideas to take away:

Views: 65

Comments

Please login to add a comment.

Don't have an account? Register now!