Knowledge

Linux command: directory /proc

Read live information through a special folder

Suppose you want to see which programs are running or how much memory Linux reports. The system exposes some current information through paths in a special directory, usually mounted at /proc. You can inspect them with familiar commands such as cat or filter their output with grep. The paths look like files, but most are generated when read rather than stored on disk. This file-like area is called procfs, short for pseudo-filesystem; its values can change between reads and usually do not persist like ordinary files.

Numbered directories such as /proc/1234 contain information about the process with that PID. Other paths describe system-wide state, including /proc/meminfo, /proc/cpuinfo, and /proc/uptime. /proc/self points to the proc directory of the process that opens it. If an external program opens /proc/self, it sees information about itself, which may not be the shell that started it.

For a process whose ID you have checked, read its status file:

cat /proc/1234/status

The file has labeled values such as Name, State, Pid, and PPid, plus selected memory, user, and group details. To print a few fields, filter the output:

grep -E '^(Name|State|Pid|PPid):' /proc/1234/status

Replace 1234 with the PID being inspected. The process may exit before the read, and access controls can restrict information about processes owned by other users. PID namespaces and container boundaries also affect which processes and identifiers are visible from a particular environment.

For system-level values, head /proc/meminfo and cat /proc/uptime show two common examples. Available fields and their formatting depend on each documented interface. Scripts should read a defined field rather than assume every kernel exposes the same complete set. ps is often easier for a process overview; /proc helps when a program needs a specific kernel-provided value.

Most procfs entries are for reading. Some paths, especially below /proc/sys, expose documented controls that can change kernel parameters. Do not assume that writing to any path is a supported configuration method. Use the documented interface, often sysctl, and check whether a change is temporary or needs a persistent setting elsewhere. Mount options and system policy can hide or restrict parts of procfs.

The file-like interface is convenient, but procfs is not a stable database of stored files. Consult the kernel documentation and local manual for the fields available on the running system.

Interactive exercises

Materials

Skillsets
Skillset Linux for backend developer preview
image descriptionLinux for backend developer
by Artem Naumenko (fb)
16 users
Skillset Linux administrator preview
image descriptionLinux administrator
by Infinite Education
3080 users
Skillset Devops preview
image descriptionDevops
by Ajay Kumar
2004 users
Skillset Skyeng SRE preview
image descriptionSkyeng SRE
by Yuliya Marochkina
12 users
Skillset Skyeng Senior PlatOps preview
image descriptionSkyeng Senior PlatOps
by Artem Naumenko (slack2)
7 users
Skillset Devops preview
image descriptionDevops
by Dio
3 users
Skillset Skyeng Ops (for DevOps) preview
image descriptionSkyeng Ops (for DevOps)
by Roman Burnashev
2 users
Do you know that ...?
Any useful or interesting facts about the skill. Any peace of information would be useful