20

The proc file system allows the kernel to communicate information about each running process on a Linux system.

Why is proc called a file system? It’s not a real file system like ext4. It’s just a collection of files containing information about the running processes.

Mat
  • 52,586

3 Answers3

26

/proc is a filesystem because user processes can navigate through it with familiar system calls and library calls, like opendir(), readdir(), chdir() and getcwd(). Even open(), read() and close() work on a lot of the "files" that appear in /proc. For most intents and almost all purposes, /proc is a filesystem, despite the fact that its files don’t occupy blocks on some disk.

I suppose we should all clarify what definition of the term “file system” we are currently using. In the context of ext4, when we write “file system”, we’re probably talking about the combination of a layout of disk blocks, specification of metadata information about the disk blocks that also resides somewhere on disk, and the code that deals with that on-disk layout. In the context of /usr, /tmp, /var/run and so on, we’re writing about an understanding or a shared conceptualization of how to name some things. Those two uses of the term “file system” are indeed quite different. /proc is really the second kind of “file system”, as you’ve noted.

TRiG
  • 331
  • 9
    There's no reason to use scary quots for files in /proc unless one thinks that files are always disk-backed (or tape-backed, or CD-backed, or whatever-backed9. They are not always - think of RAM-disks. Also, even an open/write/close sequence with a "real" file in /home, say, may not always mean that corresponding changes intended to permanently reflect the state of this file ondisk storagehave already been made and completed. – Hagen von Eitzen May 17 '15 at 20:51
  • 10
    tl;dr: because it's a system of files? – Jörg W Mittag May 17 '15 at 23:51
  • 1
    Note that this also explains the saying "In Linux, everything is a file". – dr_ May 18 '15 at 12:48
  • It's a file system in a similar way that the screen is a "desktop". Computer terminology abounds with metaphors. – Barmar May 20 '15 at 19:00
18

it's just an area of files containing information

But that's exactly what a filesystem is. Filesystems don't have to be writable and they don't have to reside on permanent storage.

Note: There's a distinction between procfs (the pseudo filesystem implementation in the kernel) and its conventional mount point /proc. You could in theory mount a procfs anywhere, but that's rare. Because of that, people often talk about /proc when they really mean procfs.

procfs is called a pseudo filesystem because files in a procfs aren't created by the usual filesystem operations, but are added and removed by the filesystem implementation itself based on what's happening elsewhere in the kernel.

cjm
  • 27,160
  • so why /etc /boot for example are not called file system??? – Lkaf Temravet May 17 '15 at 17:55
  • 8
    Because they're directories in a filesystem. (Well, /boot is frequently a separate filesystem, but it's not a separate kind of filesystem.) – cjm May 17 '15 at 17:58
9

If data are organized in a way so they can be accessed via the mechanisms used for file systems you may well call the whole thing a file system.

guntbert
  • 1,637