Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In unix/linux, what is the proc directory for? why does it exists?

What can I use it for (if not just for the system)?

share

migration rejected from stackoverflow.com yesterday

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

put on hold as off-topic by Jenny D, peterh, mdpc, MadHatter, Khaled yesterday

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions should demonstrate reasonable business information technology management practices. Questions that relate to unsupported hardware or software platforms or unmaintained environments may not be suitable for Server Fault - see the help center." – peterh, mdpc, Khaled
  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Jenny D, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

    
why did I get down voted for asking a question? I researched it, I'm still a bit confused –  CaptainHook123 Aug 16 '11 at 14:04
    
Most likely because this seems to be a very easy question to research, plus, its connection to programming is weak at best. –  Delan Azabani Aug 16 '11 at 14:07
    
In my attempts to use the nvcc cuda compiler (to program) I had to determine which cards I had. Just so happens that this directory had some information I could use (proc/driver/nvidia/0). I did see my man page first. But to erase ambiguity I posted my question. –  CaptainHook123 Aug 16 '11 at 14:16
    
Oh, okay then. Does my answer, answer your question? –  Delan Azabani Aug 16 '11 at 14:17
    
unix.stackexchange.com would probably be the best home for this question. –  Jonik Aug 17 '11 at 10:20

2 Answers 2

/proc is a Virtual filesystem which does not reside on a disk, but it resides on system memory (RAM). The files and directories in this filesystem are used by system to register processes they run and also the setting (tunables) of the operating systems get loaded from the disk to the /proc filesystem when teh system boots up, so that the system doesnt have to reach to the disk everytime it has to read some setting or values.

It Also holds some real time statistical information such as process ID's cpu memory and IO stats and kernel Values. This filesystem is useful for users to read/fetch data , when they need to read some values from the kernel.

share

The proc filesystem as a programming facility. A pseudo-filesystem rooted at /proc that contains user-accessible objects that pertain to the runtime state of the kernel and, by extension, the executing processes that run on top of it. "Pseudo" is used because the proc filesystem exists only as a reflection of the in-memory kernel data structures it displays. This is why most files and directories within /proc are 0 bytes in size.

A directory listing of /proc reveals two main file groups.

  1. Each numerically named directory within /proc corresponds to the process ID (PID) of a process currently executing on the system.

  2. The second file group within /proc is the non-numerically named directories and regular files that describe some aspect of kernel operation. As an example, the file /proc/version contains revision information relevant to the running kernel image.

    • Proc files are either read-only or read-write. The /proc/version file above is an example of a read-only file. Its contents are viewable by way of cat(1), and they remain static while the system is powered up and accessible to users.

    • Read-write files, however, allow for both the display and modification of the runtime state of the kernel. /proc/sys/net/ipv4/ip_forwarding is one such file. Using cat(1) on this file reveals if the system is forwarding IP datagrams between network interfaces--the file contains a 1--or not--the file contains a 0. In echo(1)ing 1 or 0 to this file, that is, writing to the file, we can enable or disable the kernels ability to forward packets without having to build and boot a new kernel image. This works for many other proc files with read-write permissions.

Most firewall shell scripts use the /proc file system.

share
1  
I don't see any new information in this answer not already found in the previous answers. –  kasperd Mar 23 at 20:12
    
@kasperd I have updated ans, to ans the question in one shot than in tits and bits.I hope this will help. –  Rajesh Pal May 3 at 5:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.