Notes on /proc and /sys

From FreekiWiki
Jump to navigation Jump to search

Under the Filesystem Heirarchy Standard, /proc is a directory that mounts a procfs filesystem. In newer kernels, the functions of /proc are being superseded by /sys, which uses the sysfs filesystem. These filesystems are designed to offer information about current processes, drivers, and devices running on the operating system and enable some configuration of the host operating system.

Getting information from /proc

The following are some files under /proc I find to occasionally be useful.

Hardware Information

/proc/cpuinfo
A detailed listing of the processor(s) model, speed, cache sizes, flags, and more. Corresponds to lscpu
/proc/meminfo
A verbose report on the system's memory. Corresponds to free
/proc/acpi/battery/
Directories named after batteries known to the system, with files detailing information and their current state. Corresponds to acpi
/proc/mdstat
A listing of the RAID devices known to the system and their current state. Corresponds to mdadm --detail --scan
/proc/scsi/scsi
A listing of all disk drives, their type, and which bus they reside on (including optical drives, or drives connected through external interfaces such as USB)

System Information

/proc/loadavg
Load average numbers on the system. Corresponds to uptime.
/proc/uptime
Time since the system was booted. Corresponds to uptime, and the kernel parameter printk.time.
/proc/mounts
A listing of currently mounted devices and filesystems. Corresponds to mount.
/proc/partitions
A listing of the devices, their partitions and number of blocks used known to the operating system.
/proc/swaps
A listing of all swap partitions available to the system.
/proc/kcore
A dump of the system's current memory. There is much evil fun to be had here.
/prov/self/environ
A listing of all environmental variables. Corresponds to env.
/proc/modules
A list of all modules currently loaded in the kernel. Corresponds to lsmod.
/proc/kmsg
A dump of messages from the kernel. Corresponds to dmesg (NOTE: This will empty the buffer of kernel messages)
/proc/version
Displays the kernel version, revision, architecture, compiler, etc. Corresponds to uname.

System Configuration

/proc/sys/kernel/domainname
Prints the system's domain name, if any. Corresponds to domainname, and dnsdomainname
/proc/sys/kernel/hostname
Prints the system's host name, if any. Corresponds to hostname, and dnsdomainname
/proc/sys/kernel/ctrl+alt+del
Returns either a 0 or a 1
0 indicates that the key sequence will be captured by init and initiate a graceful shutdown
1 indicates that the key sequence will not be captured, and will shutdown as though you had yanked the power plug
/proc/sys/kernel/sysrq
A non-zero integer indicates that SysRq key sequences will be acknowledged.