Understanding Linux File Systems – Part 1 (/proc file system)

About /proc filesystem

/proc file system plays very important role in System Optimization. /proc file system acts as an interface between user and kernel, we can monitor what is going on currently in our system with the help of /proc file system.

Let’s have a look in /proc/ directory.

# cd /proc/ && ls

proc1

it consists of various status files which can be utilize to monitor various status information of running system. cat command can be used to get related information.

Files name available in /proc directory

 Function

partitions

– nformation about file system available

cpuinfo

– detailed information about CPU

meminfo

– RAM status

vmstat

– Virtual memory status

Uptime

– CPU uptime()

(cat /proc/cpuinfo example snapshot)

cpuifno

/proc also include process directories which stores information related with currently running process. e.g. Have a look in pid Directory.

Lets have a look.

# cd /proc
# cd 1
# cat cmdline (it will indicate that pid 1 belongs to init process)

cmdline 1

The optimization of /proc is configured under proc/sys/ directory. Generally we set parameters into /proc/sys underneath files with “echo” command, but these changes got vanished after reboot. If you want changes to be effective permanently, then we we will use “sysctl” optimization tool. sysctl will enable changes permanently, sysctl consist of a configuration file /etc/sysctl.conf and a directory /etc/sysctl.d. We have to set parameter into /etc/sysctl.conf, sysctl optimization tool will get information from /etc/sysctl.conf and will apply those changes to kernel permanently.

proc

(a  snapshop of /etc/sysctl.conf)

sysctl.conf

We will try to understand role of sysctl with an example: let’s disable the icmp ping response permanently. Firstly we will try with echo command, then we will disable ping response with sysctl.

# sysctl –a |grep icmp

icmp_echo_ignore_all

# echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all

Verify your change and use ping command with your ip address, it will show no reply.

If we reboot system, changes will got flushed, so lets edit /etc/sysctl.conf file to make our changes permanent.

Open /etc/sysctl.conf and edit file  to disable ping response permanently.

# vim /etc/sysctl.conf

icmp_sysclt

(Note: net.ipv4 indicates file system hierarchy under /proc/sys files system i.e. /proc/sys/net/ipv4, and icmp_echo_ignore_all is the value available in /proc/sys/net/ipv4/ directory).

Reboot System and cross check parameters.