Examining /proc filesystem

Posted by Lukas Hajdu on Wed, Oct 16, 2019

The /proc directory is a special directory which holds all the details about the Linux system. Because of this reason, it can be regarded as a control and information centre for the kernel.

The directory is a mount point for a pseudo-filesystem and it doesn’t contain real files but runtime system information. Most files within this directory are zero length.

The system information is not being constantly updated, it is obtained only when one wants to look at it.

/proc directory

Each of the numbered directories corresponds to an actual process ID.

Examination of some process files

/proc/cpuinfo

The file contains information about the CPUs on a computer.

/proc directory

Description of some parameters:

ParameterDescription
processorvalue of which is zero for single-processor systems
vendor_idvalue of which is GenuineIntel in the case of an Intel processor
cpu familytype of processor in the system
model namecommon name of the processor, including its project name
cpu MHzprocessor speed in millions of cycles per second
cache sizeamount of high-speed cache memory built into the processor
fpuvalue of which is yes if the processor contains a floating-point unit

/proc/meminfo

The file contains information about the system’s RAM usage, both physical and swap. Much of the information in /proc/meminfo is used by the free, top, and ps commands.

/proc directory

Note: While the file shows kilobytes (kB; 1 kB equals 1000 B), it is actually kibibytes (KiB; 1 KiB equals 1024 B). This imprecision in /proc/meminfo is known but is not corrected due to legacy concerns.

Description of some parameters:

ParameterDescription
MemTotaltotal amount of usable RAM (physical RAM minus a number of reserved bits and the kernel binary code)
MemFreeamount of physical RAM left unused by the system
Buffersamount of temporary storage for raw disk blocks
Cachedamount of physical RAM used as cache memory
SwapCachedamount of memory that has once been moved into swap, then back into the main memory, but still also remains in the swapfile. This saves I/O, because the memory does not need to be moved into swap again.

/proc/mounts

This file provides a list of all mounts in use by the system:

1lukash@ubuntu:/proc$ cat mounts 
2sysfs       /sys    sysfs       rw,nosuid,nodev,noexec,relatime 0 0
3proc        /proc   proc        rw,nosuid,nodev,noexec,relatime 0 0
4udev        /dev    devtmpfs    rw,nosuid,relatime,size=473408k,nr_inodes=118352,mode=755 0 0
5tmpfs       /run    tmpfs       rw,nosuid,noexec,relatime,size=100916k,mode=755 0 0
6/dev/sda2   /       ext4        rw,relatime,data=ordered 0 0
7...

Description of individual columns:

ColumnDescription
1stmounted device
2ndmount point
3rdfile system type
4thmounted read-only (ro) or read-write (rw)
5th/6thdummy values

/proc/swaps

This file measures swap space and its utilization. It provides a snapshot of every swap file.

/proc directory

Description of individual columns:

ColumnDescription
Filenamefile name
Typetype of swap space
Sizetotal size
Usedamount of space in use (kB)
Priorityuseful when multiple swap files are in use. The lower the priority, the more likely the swap file is to be used

/proc/version

This file specifies the version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation. It also contains the kernel compiler’s user name.

1lukash@ubuntu:/proc$ cat version
2Linux version 4.15.0-65-generic (buildd@lgw01-amd64-006) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019

/proc/partitions

This file contains partition block allocation information.

1lukash@ubuntu:/proc$ cat partitions 
2major minor  #blocks  name
3
4   7        0      91140 loop0
5   7        1      91264 loop1
6  11        0    1048575 sr0
7   8        0    8388608 sda
8   8        1       1024 sda1
9   8        2    8385536 sda2

Description of individual columns:

ColumnDescription
majormajor number of the device with this partition
minorminor number of the device with this partition
#blocksnumber of physical disk blocks contained in a particular partition
namename of the partition

/proc/interrupts

This file records the number of interrupts per IRQ on the x86 architecture

/proc directory

Description of individual columns:

ColumnDescription
1strefers to the IRQ number
2ndnumber of interrupts per IRQ
3rdtype of interrupt
4rdname of the device that is located at the IRQ

Note: Each CPU in the system has its own column and its own number of interrupts per IRQ. The example above is for single-processor machine.

Examination of random process directory

Details of any process in the directory can be obtained by looking at the associated files in the directory for this process.

/proc directory

The purpose of some files in the folder:

ColumnDescription
cmdlinecommand-line arguments
cpucurrent and last cpu in which it was executed
cwdlink to the current working directory
environvalues of environment variables
memmemory held by this process
statusprocess status in human-readable form

Further reading



comments powered by Disqus