Difference between revisions of "Notes on /proc and /sys"

From FreekiWiki
Jump to navigation Jump to search
(Created page with "Under the [http://www.pathname.com/fhs/ Filesystem Heirarchy Standard], <code>/proc</code> is a directories that mounts a [http://en.wikipedia.org/wiki/Procfs procfs] filesystem.…")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Under the [http://www.pathname.com/fhs/ Filesystem Heirarchy Standard], <code>/proc</code> is a directories that mounts a [http://en.wikipedia.org/wiki/Procfs procfs] filesystem.  In newer kernels, the functions of <code>/proc</code> are being superseded by <code>/sys</code>, which uses the [http://en.wikipedia.org/wiki/Sysfs 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.
+
Under the [http://www.pathname.com/fhs/ Filesystem Heirarchy Standard], <code>/proc</code> is a directory that mounts a [http://en.wikipedia.org/wiki/Procfs procfs] filesystem.  In newer kernels, the functions of <code>/proc</code> are being superseded by <code>/sys</code>, which uses the [http://en.wikipedia.org/wiki/Sysfs 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 <code>/proc</code>==
 
==Getting information from <code>/proc</code>==
Line 17: Line 17:
 
===System Information===
 
===System Information===
 
;<code>/proc/loadavg</code>
 
;<code>/proc/loadavg</code>
:Load average numbers on the system.  Corresponds to <code>uptime</code>
+
:Load average numbers on the system.  Corresponds to <code>uptime</code>.
 
;<code>/proc/uptime</code>
 
;<code>/proc/uptime</code>
:Time since the system was booted.  Corresponds to <code>uptime</code>, and the kernel parameter <code>printk.time</code>
+
:Time since the system was booted.  Corresponds to <code>uptime</code>, and the kernel parameter <code>printk.time</code>.
 
;<code>/proc/mounts</code>
 
;<code>/proc/mounts</code>
:A listing of currently mounted devices and filesystems.  Corresponds to <code>mount</code>
+
:A listing of currently mounted devices and filesystems.  Corresponds to <code>mount</code>.
 
;<code>/proc/partitions</code>
 
;<code>/proc/partitions</code>
:A listing of the devices, their partitions and number of blocks used known to the operating system
+
:A listing of the devices, their partitions and number of blocks used known to the operating system.
 
;<code>/proc/swaps</code>
 
;<code>/proc/swaps</code>
:A listing of all swap partitions available to the system
+
:A listing of all swap partitions available to the system.
 
;<code>/proc/kcore</code>
 
;<code>/proc/kcore</code>
 
:A dump of the system's current memory.  There is much <del>evil</del> fun to be had here.
 
:A dump of the system's current memory.  There is much <del>evil</del> fun to be had here.
 
;<code>/prov/self/environ</code>
 
;<code>/prov/self/environ</code>
:A listing of all environmental variables.  Corresponds to <code>env</code>
+
:A listing of all environmental variables.  Corresponds to <code>env</code>.
 
;<code>/proc/modules</code>
 
;<code>/proc/modules</code>
:A list of all modules currently loaded in the kernel.  Corresponds to <code>lsmod</code>
+
:A list of all modules currently loaded in the kernel.  Corresponds to <code>lsmod</code>.
 +
;<code>/proc/kmsg</code>
 +
:A dump of messages from the kernel.  Corresponds to <code>dmesg</code> (NOTE: This will empty the buffer of kernel messages)
 +
;<code>/proc/version</code>
 +
:Displays the kernel version, revision, architecture, compiler, etc.  Corresponds to <code>uname</code>.
  
 
===System Configuration===
 
===System Configuration===

Latest revision as of 16:51, 28 December 2012

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.