Use the Contents of the proc Directory to Interact with the Kernel

The content of the /proc directory is created from memory and only exists 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:

$ free total used free shared buffers cached

Mem: 1036096 1022940 13156 0 121780 476892

-/+ buffers/cache: 424268 611828

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:

$ cat /proc/meminfo

MemTotal:

MemFree:

Buffers:

Cached:

SwapCached:

Active:

Inactive:

HighTotal:

HighFree:

LowTotal:

LowFree:

SwapTotal:

SwapFree:

Dirty:

Writeback:

Mapped:

Slab:

CommitLimit:

Committed_AS:

PageTables:

VmallocTotal:

VmallocUsed:

1036096 kB

12024 kB

121808 kB

477672 kB

0 kB

609764 kB 286756 kB

131008 kB

168 kB

905088 kB 11856 kB

403412 kB 103856 kB 518048 kB 771220 kB 2432 kB 114680 kB 10596 kB

VmallocChunk: 103800 kB

The /proc directory can also be used to dynamically alter the behavior of a running Linux kernel by "echoing" numerical values to specific files under the /proc/sys directory.

The Linux kernel has a number of built-in protections, but good system administration security policies and a secure firewall protecting your gateway, router, or Internet-connected system are the best protection you can use.

Other ways to use the /proc directory include

• Getting CPU information, such as the family, type, and speed from /proc/cpuinfo.

• Viewing important networking information under /proc/net, such as active interfaces information under /proc/net/dev, routing information in /proc/net/route, and network statistics in /proc/net/netstat.

• Retrieving file system information.

• Reporting media mount point information via USB; for example, the Linux kernel will report what device to use to access files (such as /dev/sda) if a USB camera or hard drive is detected

Was this article helpful?

0 0

Post a comment