The /proc filesystem
/proc
is an in-memory pseudo filesystem that provides user-space access to many of the Linux kernel's internal data structures. Most pseudo files are read-only, but some, such as /proc/sys/net/ipv4/forward
(described in Chapter 8, The Old-Boy Network), can be used to fine-tune your system's behavior.
How to do it...
The /proc
directory contains several files and directories. You can view most files in /proc
and their subdirectories with cat
, less
, or more
. They are displayed as plain text.
Every process running on a system has a directory in /proc
, named according to the process's PID.
Suppose Bash is running with PID 4295
(pgrep bash
); in this case, /proc/4295
will exist. This folder will contain information about the process. The files under /proc/PID
include:
environ
: This contains the environment variables associated with the process.cat /proc/4295/environ
will display the environment variables passed to the process4295
.cwd
: This is asymlink
to the process's working...