0

/proc is a directory we find in root in linux. it contains processes' information. but actually, process table and all that stuff is stored in kernel which is in RAM. please answer my query. I may sound silly as i am new here.

1 Answer 1

6

From the manual page:

The proc filesystem is a pseudo-filesystem which provides an interface to kernel data structures.

/proc is not secondary storage. /proc, just like /sys, is a filesystem that provides a window into the kernel. /proc/1234/cmdline, as an example, is not a disk file. It doesn't occupy any space with the possible exception of an inode. When you read from that file, you actually access kernel memory.

You can see that /proc is not a normal filesystem when you try to write to some of its files. As root, try echo blabla > /proc/$$/cmdline. You will be greeted with echo: write error: Invalid argument. cmdline can only be read, even by root. Likewise, /sys contains files that can only be written. For example, try cat /sys/block/sda/device/delete (but don't write into it - you would logically remove the sda device from your system. Should you do it accidentally, the easiest remedy is to reboot).

A similar case is /dev/kmem. It's not a file system, but a device file, and it gives you access to kernel memory. It does not refer to a storage device.

Caveat: Writing to, and perhaps even reading from, some of the files in /proc and /sys can be risky and is best done on a test machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .