Penguin
Note: You are viewing an old revision of this page. View the current version.

Under linux, there is a special filesystem mounted under /proc that gives access to the linux kernel settings and information.

Some of the information you can find includes:

  • a subdirectory for each current process. You can find things like the command line, the environment, memory and file usage. There is a special directory called "self" that refers to whichever process accesses it. For example, you can do "less /proc/self/status" to find out about the less process, or you can do "cd /proc/self ; less status" to find out about your shell process.
  • /proc/cpuinfo gives information about the detected CPU(s), including manufacturer, id, known bugs, and extensions.
  • filesystems and peripherals. For example, when you attach a USB device such as a DigitalCamera, your programs communicate with the device through a file with a name like /proc/bus/usb/001/003.
  • network devices and status.

Also, the root user can change some kernel settings by writing to particular values. For example, to allow your linux machine to act as a router by forwarding packets from other machines, it is necessary (but often automatic) to do "echo 1 > /proc/sys/net/ipv4/ip_forward".

Writing programs that get information from /proc is a good way to make them non-portable to other unix(-like) systems.

See also ProcessNotes, procinfo(8), proc(5).