Exploring /proc
Using the /proc/sys file system to parse kernel parameters.
Another very important part of the /proc file system is the /proc/sys
directory. Making changes in this directory enables you to make real time
changes to certain kernel parameters. One fine example that can illustrate
this is as follows.
/proc/sys/net/ipv4/ip_forward
The above file ip_forward has a default value of "0" which you can see
when you cat the contents of this file. This means that IP forwarding by
this machine isn't allowed by the kernel. But this configuration can be
changed in real time by just changing the value stored in this file from
"0" to "1". Thus we have enabled IP forwarding on our Linux machine.
The output of the directory listing of the /proc directory is as follows.
The actual listing was really lengthy. What's given below is a much
shorter version.
1 114 1210 1211 1212 1227 133 137 148 160 161 163 167 168 169
170 171 172 173 174 186 190 193 194 195 203 206 207 208 209
210 211 220 221 222 223 224 225 226 227 229 230 234 246 253 279
296 3 4 5 500 501 6 667 668 669 683 684 685 7 711 712 713 737 763
764 765 766 773 774 775 782 79 88 92 asound bus cmdline config.gz
cpuinfo devices dma fb filesystems fs ide interrupts ioports
kcore kcore_elf kmsg ksyms loadavg locks lvm mdstat meminfo
memstat misc modules mounts net partitions pci rtc scsi self
slabinfo stat swaps sys tty uptime version
Every number and word that you see in the above snapshot are the contents of
the /proc directory. Lets learn a little more about the contents of the
directories with the numerical naming scheme.
1 114 1210 1211 1212 1227 133 137 148 160 161 163 167 168 169
170 171 172 173 174 186 190 193 194 195 203 206 207 208 209
210 211 220 221 222 223 224 225 226 227 229 230 234 246 253 279
296 3 4 5 500 501 6 667 668 669 683 684 685 7 711 712 713 737 763
764 765 766 773 774 775 782 79 88 92
The various directories that you see out here are the processes that were
running on our machine at the instant we took a snapshot of the /proc
file system. Let's look at the contents of one of these directories.
freeos:~ # cd /proc
freeos:/proc # ls -la 114
total 0
dr-xr-xr-x 3 named named 0 Nov 30 12:20 .
dr-xr-xr-x 89 root root 0 Nov 30 2000 ..
- « first
- ‹ previous
- of 4
- next ›
- last »