Everything is awesome! I mean, in Linux, everything is a file! We even saw where devices are files. But we also have processes, things that run and do things. Are they files? Well, the answer is… (drum roll)…yes. Everything is a file. Where devices are in /dev, process are in /proc. That kind of makes sense, right?
If you ls /, the top directory on your system, you’ll see something like:
bin dev home lost+found misc net opt root selinux sys usr boot etc lib media mnt od proc sbin srv tmp var
So let’s cd into /proc and look around:
1 13 19 2705 2957 328 6 devices kmsg softirqs 10 14 2 2769 2972 329 6960 diskstats kpagecount stat 1013 14761 20 2771 2985 33 6962 dma kpageflags swaps 1043 14766 21 2791 2986 330 6963 drbd loadavg sys 1067 15 22 2794 2988 331 7 driver locks sysrq-trigger 1076 158 23 28 3 332 8 execdomains mdstat sysvipc 1095 16 24 2803 314 333 9 filesystems meminfo timer_list 11 160 24853 2841 315 334 901 fs misc tty 1102 162 25 2882 316 335 buddyinfo interrupts modules uptime 1150 17 25077 29 320 336 bus iomem mounts version 1152 171 25265 2901 32082 337 cmdline ioports net vmallocinfo 1153 1743 255 2915 322 338 config.gz irq pagetypeinfo vmstat 1161 1745 257 2932 325 339 consoles kallsyms partitions zoneinfo 1173 1746 26 2940 326 34 cpuinfo kcore self 12 18 27 2949 327 5 crypto key-users slabinf
The numbers in proc correspond to processes that are currently running on your Linux system. On this system, there’s a process numbered 29 and one numbered 2901. There’s even 1150, 1152 and 1153. This system isn’t that busy, there’s only 98 processes currently running on it. That may seem like a lot, but a busy web server or a busy mail server could have a thousand busy processes.
Each one of those numbers is a directory and in that directory are files (see what I did there) that are information for that process. I looked in /proc/1 and saw:
ls: cannot read symbolic link 1/cwd: Permission denied ls: cannot read symbolic link 1/root: Permission denied ls: cannot read symbolic link 1/exe: Permission denied attr/ coredump_filter fdinfo/ mem oom_adj root@ status auxv cwd@ io mountinfo oom_score sessionid syscall clear_refs environ limits mounts oom_score_adj smaps task/ cmdline exe@ loginuid mountstats pagemap stat wchan comm fd/ maps net/ personality statm
What do those first three lines mean? Well, they mean I don’t really have permission to loo at everything in this directory. I could see that further if I did an <b>ls -l</b> on it, but this is really just to show you what’s in the directory.
Next time we’ll talk about some of the files in the /proc directory.