You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

172 lines
6.0 KiB

= procfs !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro
:keywords: procfs
:data-uri:
:toc: right
:toc-title: Πίνακας περιεχομένων
:toclevels: 4
:source-highlighter: highlight
:icons: font
:sectnums:
{empty} +
.procfs
****
The proc filesystem (*procfs*) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure,
*providing* a more convenient and *standardized method for dynamically accessing process* data held in the kernel than traditional tracing methods or direct access to kernel memory.
Typically
- it is mapped to a mount point named /proc at boot time.
- The proc file system acts as an interface to internal data structures in the kernel.
- It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).
****
== The /proc Filesystem
NOTE: The proc filesystem provides a method of communication between *kernel space* and *user space*. For example, the GNU version of the process reporting utility *ps* uses the proc file system to obtain its data, without using any specialized system calls.
The directory /proc contains (among other things) one subdirectory for each process running on the system, which is named after the process ID (PID).
The link ‘self’ points to the process reading the file system. Each process subdirectory has the entries listed in: ls /proc/<pid>
[source,bash]
----
cat /proc/meminfo
MemTotal: 8174328 kB
MemFree: 6186516 kB
MemAvailable: 7535332 kB
Buffers: 146740 kB
Cached: 1294156 kB
SwapCached: 0 kB
Active: 967184 kB
Inactive: 606252 kB
Active(anon): 135620 kB
Inactive(anon): 85064 kB
Active(file): 831564 kB
Inactive(file): 521188 kB
Unevictable: 3652 kB
Mlocked: 3652 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 68 kB
Writeback: 0 kB
AnonPages: 136188 kB
Mapped: 113344 kB
Shmem: 85724 kB
Slab: 340236 kB
SReclaimable: 302048 kB
SUnreclaim: 38188 kB
KernelStack: 3792 kB
PageTables: 4888 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 4087164 kB
Committed_AS: 901432 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 51200 kB
CmaTotal: 0 kB
CmaFree: 0 kB
...
----
.Main entries in /proc
[options="header,footer"]
|=======================
|File|Content
| /proc/cmdline | – Kernel command line information.
| /proc/console | – Information about current consoles including tty.
| /proc/crypto | - a list of available cryptographic modules
| /proc/devices | – Device drivers currently configured for the running kernel.
| /proc/diskstats | - giving some information (including device numbers) for each of the logical disk devices
| /proc/dma | – Info about current DMA channels.
| /proc/fb | – Framebuffer devices.
| /proc/filesystems | – Current filesystems supported by the kernel.
| /proc/interrupts, /proc/iomem, /proc/ioports and the directory /proc/irq | - giving some self-explanatory details about the devices (physical or logical) using the various system resources
| /proc/iomem | – Current system memory map for devices.
| /proc/ioports | – Registered port regions for input output communication with device.
| /proc/loadavg | – System load average.
| /proc/locks | – Files currently locked by kernel.
| /proc/meminfo | – Info about system memory (see above example).
| /proc/misc | – Miscellaneous drivers registered for miscellaneous major device.
| /proc/modules | - one of the most important files in /proc, containing a list of the kernel modules currently loaded . It gives some indication (not always entirely correct) of dependencies.
| /proc/mounts | – List of all mounts in use by system.
| /proc/mounts | - a symlink to self/mounts which contains a list of the currently mounted devices and their mount points (and which file system is in use and what mount options are in use).
| /proc/net | - a directory containing useful information about the network stack, in particular /proc/net/nf_conntrack, which lists existing network connections (particularly useful for tracking routing when iptables FORWARD is used to redirect network connections)
| /proc/partitions | – Detailed info about partitions available to the system.
| /proc/pci | – Information about every PCI device.
| /proc/stat | – Record or various statistics kept from last reboot.
| /proc/swap | – Information about swap space.
| /proc/scsi | - giving information about any devices connected via a SCSI or RAID controller
| /proc/sysvipc | - containing memory-sharing and inter-process communication (IPC) information.
| /proc/tty | - containing information about the current terminals; /proc/tty/driver looks to be[original research?] a list of the different types of tty available - each of which is a list of those of each type
| /proc/uptime | – Uptime information (in seconds).
| /proc/version | – Kernel version, gcc version, and Linux distribution installed.
|=======================
== cpu info
[source,bash]
----
cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 2000.000
cache size : 1024 KB
...
processor : 1
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 800.000
cache size : 1024 KB
----