Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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|improve this question

migrated from stackoverflow.com Aug 17 '11 at 10:04

This question came from our site for professional and enthusiast programmers.

    
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

3 Answers 3

up vote 12 down vote accepted

procfs (or the proc filesystem) is a special filesystem in UNIX-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /proc at boot time.

Examples:

  • inside /proc, there is a directory for each running process, named with its process ID. These directories contain files that have useful information about the processes, such as
    • exe, which is a symbolic link to the file on disk the process was started from
    • cwd, which is a symbolic link to the working directory of the process
    • wchan, which, when read, returns the waiting channel the process is on
    • maps, which, when read, returns the memory maps of the process
  • /proc/cmdline returns the command line passed to the running kernel
  • /proc/cpuinfo returns information about the running CPUs
  • /proc/uptime returns the uptime as two decimal values in seconds, separated by a space:
    • the amount of time since the kernel was started
    • the amount of time that the kernel has been idle
  • /proc/version returns detailed information about the kernel; more than you'd get from uname -a
share|improve this answer

From the proc man page:

   The proc file system is a pseudo-file system which is used as an inter‐
   face to kernel data structures.  It is commonly mounted at /proc.  Most
   of  it  is  read-only,  but  some  files  allow  kernel variables to be
   changed.
share|improve this answer

Its main use is for debuggers and other diagnostic programs. For example, "top" and "ps" examine its contents to determine what processes are running.

gdb and such like, also use proc (also ptrace system call) to examine the process's memory.

Additionally it provides some system-wide information (uptime, version etc) which may be useful for some programs.

And a bunch of other things - for example the "sysctl" kernel tunable parameters are in /proc/sys.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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