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 process 4295.
- cwd: This is a symlink to the process's working directory.
- exe: This is a symlink to the process's executable:
$ readlink /proc/4295/exe
/bin/bash
- fd: This is the directory consisting of entries on file descriptors used by the process. The values 0, 1, and 2 are stdin, stdout, and stderr, respectively.
- io: This file displays the number of characters read or written by the process.