**The Proc File System**
Today I have come to know these all things about Proc File System. really so Interesting.
The proc filesystem is a special filesystem found on most UNIX-based systems.It holds a great deal of information, in ASCII format, most of which is not very friendly to the average user.It is important that you keep in mind that the files under /proc are not kept on a physical storage, meaning they are subject to change after reboot. Also, they should not really be called files as they are pseudo-files, as they exist only in memory.
I break that rule on regular basis and intend to do that also in this article.
I’ve made a list of some of the files i find to be of most use.
/proc/[pid]/
/proc contains a directory named after the PID (process identification number) of each excising process on the system.
Lets take a look at some of the files found there.
Contains all the arguments passed to the kernel at boot time.
/proc/cpuinfo
Perhaps the most known one, it contains processor related information, such as the architecture, frequency and amount of cache found on the cpu.
/proc/filesystems
A list of all the file systems supported by the current kernel.
Lines beginning with ‘nodev’ indicate non-physical filesystems such as network filesystems and proc.
/proc/loadavg
Holds information regarding the load average of the system.
The first three fields are the same ones you get from ‘uptime’.
The fourth field consists of two numbers seperated by a slash, the first one represents the number of currently executing processes/threads. This number will not exceed the number of processors cores the system has.
The second number (the one after the slash) represents the number of processes/threads currently existing on the system.
The fifth field is the PID of the process most recently created.Now, this is where you need to be careful.If you execute ‘cat /proc/loadav’, then this number will represent the PID of the cat command you just executed!
/proc/free
Contains statistics about memory usage.
The command ‘free’ makes use of this file to build its output.
/proc/net/
This directory holds alot of files rated to the networking layer.
All the files are ASCII structured and can be read.
Shows the amount of swap in use and the priority of the defined swap partitions.
/proc/sys/kernel/hostname
Contains the current hostname of the system.
You can change this by executing “echo ‘newHostname’ > /proc/sys/kernel/hostname”
/proc/sys/kernel/threads-max
Specifies the maximum number of processess/threads that can excist at any given time on the system.
Compare this to the current number of processes/threads from the fourth field in /proc/loadavg
/proc/sys/vm/swappiness
The value in this file controls how willing the kernel will be to swap memory.
If you raise this number, the kernel will want to swap more often, while lowering it will decrease his tendency to swap.
The default value is 60.
/proc/uptime
Contains two numbers, the first one tells you how long the system has been up (in seconds), while the second one tells you for how long it has been idle.
You can use something like:echo `cut -d’ ‘ -f2 /proc/uptime` / `cut -d’ ‘ -f1 /proc/uptime` | bc -l to get the percentage of idle time on your computer.
/proc/vmstat
Contains virtual memory statistics
/proc/sys/net/ipv4/conf/default/forwarding
Controls whether the kernel will allow tcp forwarding.The default value is 0 which means forwarding is OFF.You can set this to 1 if you with to enable it…
Think: Internet connection sharing without password protection.
Kuldeep
!Enjoy Linux
Today I have come to know these all things about Proc File System. really so Interesting.
The proc filesystem is a special filesystem found on most UNIX-based systems.It holds a great deal of information, in ASCII format, most of which is not very friendly to the average user.It is important that you keep in mind that the files under /proc are not kept on a physical storage, meaning they are subject to change after reboot. Also, they should not really be called files as they are pseudo-files, as they exist only in memory.
I break that rule on regular basis and intend to do that also in this article.
I’ve made a list of some of the files i find to be of most use.
/proc/[pid]/
/proc contains a directory named after the PID (process identification number) of each excising process on the system.
Lets take a look at some of the files found there.
/proc/[pid]/cmdline
Contains the command line used to launch the process.
/proc/[pid]/cwd
This is a symbolic link to the current working directory of the process.
If you have a process with the PID 1234, then you can find out it’s current working directory by using the command “cd /proc/1234/cwd; /bin/pwd”
If you have a process with the PID 1234, then you can find out it’s current working directory by using the command “cd /proc/1234/cwd; /bin/pwd”
/proc/[pid]/status
This file contains information about the processes status, such as it’s name, state, pid, parent pid, owner.
/proc/cmdlineContains all the arguments passed to the kernel at boot time.
/proc/cpuinfo
Perhaps the most known one, it contains processor related information, such as the architecture, frequency and amount of cache found on the cpu.
/proc/filesystems
A list of all the file systems supported by the current kernel.
Lines beginning with ‘nodev’ indicate non-physical filesystems such as network filesystems and proc.
/proc/loadavg
Holds information regarding the load average of the system.
The first three fields are the same ones you get from ‘uptime’.
The fourth field consists of two numbers seperated by a slash, the first one represents the number of currently executing processes/threads. This number will not exceed the number of processors cores the system has.
The second number (the one after the slash) represents the number of processes/threads currently existing on the system.
The fifth field is the PID of the process most recently created.Now, this is where you need to be careful.If you execute ‘cat /proc/loadav’, then this number will represent the PID of the cat command you just executed!
/proc/free
Contains statistics about memory usage.
The command ‘free’ makes use of this file to build its output.
/proc/net/
This directory holds alot of files rated to the networking layer.
All the files are ASCII structured and can be read.
/proc/net/arp
Holds the arp table
/proc/net/dev
Information such as the total number of received and transmitted packets and bytes by each network interface.
/proc/net/route
Holds the routing table, in hexademical format.
/proc/net/wireless
Holds information related to the current wireless connection, such as thequality and number of discarded packets.
/proc/swapsShows the amount of swap in use and the priority of the defined swap partitions.
/proc/sys/kernel/hostname
Contains the current hostname of the system.
You can change this by executing “echo ‘newHostname’ > /proc/sys/kernel/hostname”
/proc/sys/kernel/threads-max
Specifies the maximum number of processess/threads that can excist at any given time on the system.
Compare this to the current number of processes/threads from the fourth field in /proc/loadavg
/proc/sys/vm/swappiness
The value in this file controls how willing the kernel will be to swap memory.
If you raise this number, the kernel will want to swap more often, while lowering it will decrease his tendency to swap.
The default value is 60.
/proc/uptime
Contains two numbers, the first one tells you how long the system has been up (in seconds), while the second one tells you for how long it has been idle.
You can use something like:echo `cut -d’ ‘ -f2 /proc/uptime` / `cut -d’ ‘ -f1 /proc/uptime` | bc -l to get the percentage of idle time on your computer.
/proc/vmstat
Contains virtual memory statistics
/proc/sys/net/ipv4/conf/default/forwarding
Controls whether the kernel will allow tcp forwarding.The default value is 0 which means forwarding is OFF.You can set this to 1 if you with to enable it…
Think: Internet connection sharing without password protection.
Kuldeep
!Enjoy Linux