Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

Using the Contents of the /proc Directory to


Interact with the Kernel


The contents of the /proc directory are created from memory and exist only
while Linux is running. This directory contains special files that either extract
information from or send information to the kernel. Many Linux utilities
extract information from dynamically created directories and files under this
directory, also known as a virtual file system. For example, the free
command obtains its information from a file named meminfo:


Click here to view code image
matthew@seymour:~$ free


                                        total                           used                            free                        shared          buffers
cached
Mem: 4055680 2725684 1329996 0 188996
1551464
-/+ buffers/cache: 985224 3070456
Swap: 8787512 0 8787512

This information constantly changes as the system is used. You can get the
same information by using the cat command to see the contents of the
meminfo file:


Click here to view code image
matthew@seymour:~$ cat /proc/meminfo
MemTotal: 4055680 KB
MemFree: 1329692 KB
Buffers: 189208 KB
Cached: 1551488 KB
SwapCached: 0 KB
Active: 1222172 KB
Inactive: 1192244 KB
Active(anon): 684092 KB
Inactive(anon): 16 KB
Active(file): 538080 KB
Inactive(file): 1192228 KB
Unevictable: 48 KB
Mlocked: 48 KB
SwapTotal: 8787512 KB
SwapFree: 8787512 KB
Dirty: 136 KB
Writeback: 0 KB
AnonPages: 673760 KB
Mapped: 202308 KB
Shmem: 10396 KB
Slab: 129248 KB
SReclaimable: 107356 KB

Free download pdf