5.3. Directories within /proc/
Common groups of information concerning the kernel are grouped into directories and subdirectories within the
/proc/
directory.
5.3.1. Process Directories Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Every
/proc/
directory contains a number of directories with numerical names. A listing of them may be similar to the following:
These directories are called process directories, as they are named after a program's process ID and contain information specific to that process. The owner and group of each process directory is set to the user running the process. When the process is terminated, its
/proc/
process directory vanishes.
Each process directory contains the following files:
cmdline
— Contains the command issued when starting the process.cwd
— A symbolic link to the current working directory for the process.environ
— A list of the environment variables for the process. The environment variable is given in all upper-case characters, and the value is in lower-case characters.exe
— A symbolic link to the executable of this process.fd
— A directory containing all of the file descriptors for a particular process. These are given in numbered links:Copy to Clipboard Copied! Toggle word wrap Toggle overflow maps
— A list of memory maps to the various executables and library files associated with this process. This file can be rather long, depending upon the complexity of the process, but sample output from thesshd
process begins like the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow mem
— The memory held by the process. This file cannot be read by the user.root
— A link to the root directory of the process.stat
— The status of the process.statm
— The status of the memory in use by the process. Below is a sample/proc/statm
file:263 210 210 5 0 205 0
263 210 210 5 0 205 0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The seven columns relate to different memory statistics for the process. From left to right, they report the following aspects of the memory used:- Total program size, in kilobytes.
- Size of memory portions, in kilobytes.
- Number of pages that are shared.
- Number of pages that are code.
- Number of pages of data/stack.
- Number of library pages.
- Number of dirty pages.
status
— The status of the process in a more readable form thanstat
orstatm
. Sample output forsshd
looks similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The information in this output includes the process name and ID, the state (such asS (sleeping)
orR (running)
), user/group ID running the process, and detailed data regarding memory usage.
5.3.1.1. /proc/self/ Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The
/proc/self/
directory is a link to the currently running process. This allows a process to look at itself without having to know its process ID.
Within a shell environment, a listing of the
/proc/self/
directory produces the same contents as listing the process directory for that process.