sysfs
makes perfect sense -- it represents the system, and is mounted under /dev
. procfs
, which gets mounted to /proc
, is much more nebulous however. What are procfs
& /proc
used for?
sysfs
makes perfect sense -- it represents the system, and is mounted under /dev
. procfs
, which gets mounted to /proc
, is much more nebulous however. What are procfs
& /proc
used for?
Historically (years before Linux),
/proc
came first, and contained one file per process. Each (pseudo)-file provided access to the memory of the process, e.g., reading byte number 0x1234 from the file gave you the contents of address 0x1234 in the process's virtual memory. This interface was used by commands such asps
(the original process information viewer) and debuggers.Subsequent variants of Unix copied the principle, but not the details. For example, on Linux, there is one directory per process, containing various information in a readable form. For example
/proc/1/cwd
is a symbolic link to the current working directory of process 1, and/proc/1/cmdline
is a file containing the command line arguments.Because it was there, Linux also used
/proc
to provide system information, such as/proc/cpuinfo
containing information about the CPU (microprocessor) and/proc/bus/usb/
containing information about USB devices. The documentation of/proc
is in the kernel documentation infilesystems/proc.txt
.Later,
/sys
(thesysfs
filesystem) came to provide information about the kernel. For example, there is information about USB devices under/sys/bus/usb
(in a different format from/proc/bus/usb
), and information about kernel modules (as well as interfaces to control some modules) under/sys/modules
.Note that
/proc/sys
is not the same thing as/sys
./proc/sys
shows a specific set of runtime-configurable kernel parameters called sysctl parameters.You will find more historical and current information about
/proc
on Wikipedia.¹ or more precisely, the
proc
filesystem, which can be mounted in other locations (but not having it available at/proc
will break a lot of programs)./proc
is a real-time api to the kernel. You can set kernel variables, or retrieve kernel information. procfs is analogically a file system simulation to be able to communicate with the kernel via the file system.Each process has its own directory under
/proc
with the process id as the name. In this directory you can find all kind of information the kernel has for the particular process.Other directories allow to either get kernel statistics (like
/proc/meminfo
) or information (like/proc/cpuinfo
) or you can configure certain things (like/proc/sys/vm/swappiness
allows you to change how the kernel will use the swap space).procfs presents information about your running processes.
For example:
A bit of a variation on some answers.
/proc
is a file-system representation of the currently running processes. You don't go anywhere special, if you can read files, you can interact with the kernel.procfs
is just the implementation of that.The philosophy here is: Use the small tools like grep and friends to interact with things like processes vs writing specialized tools to interact with processes.