by Rich Simms on Mon Oct 27, 2008 5:41 pm
Nope, you are seeing how the kernel is dealing with the processes it is running for you.
The /proc directory is not a directory of files located on the hard drive. Its is mapped directly into the kernel so you can view kernel tables and process information.
Here is a little experiment. Open two Putty sessions into Opus. In one session issue the find command from step 4 of the lab. In the other session (and you need to be real fast) issue a ps -e command.
Cat myfiles in session 1 and you will see a ton of /proc files:
[code]/proc/27128
/proc/27128/task
/proc/27128/task/27128
/proc/27128/task/27128/attr
/proc/27128/attr
/proc/27129
/proc/27129/task
/proc/27129/task/27129
/proc/27129/task/27129/fd
/proc/27129/task/27129/fd/0
/proc/27129/task/27129/fd/1
/proc/27129/task/27129/fd/2
/proc/27129/task/27129/fd/255
/proc/27129/task/27129/environ
/proc/27129/task/27129/auxv
/proc/27129/task/27129/status
/proc/27129/task/27129/cmdline
/proc/27129/task/27129/stat
/proc/27129/task/27129/statm
/proc/27129/task/27129/maps
/proc/27129/task/27129/mem
/proc/27129/task/27129/cwd
/proc/27129/task/27129/root
/proc/27129/task/27129/exe
/proc/27129/task/27129/mounts
/proc/27129/task/27129/smaps
/proc/27129/task/27129/attr
/proc/27129/task/27129/attr/current
/proc/27129/task/27129/attr/prev
/proc/27129/task/27129/attr/exec
/proc/27129/task/27129/attr/fscreate
/proc/27129/task/27129/attr/keycreate
/proc/27129/task/27129/attr/sockcreate
/proc/27129/task/27129/wchan
/proc/27129/task/27129/schedstat
/proc/27129/task/27129/cpuset
/proc/27129/task/27129/oom_score
/proc/27129/task/27129/oom_adj
/proc/27129/task/27129/loginuid
/proc/27129/task/27129/limits
/proc/27129/task/27129/limits
/proc/27129/fd
/proc/27129/fd/0
/proc/27129/fd/1
/proc/27129/fd/2
/proc/27129/fd/255
/proc/27129/environ
/proc/27129/auxv
/proc/27129/status
/proc/27129/cmdline
/proc/27129/stat
/proc/27129/statm
/proc/27129/maps
/proc/27129/mem
/proc/27129/cwd
/proc/27129/root
/proc/27129/exe
/proc/27129/mounts
/proc/27129/mountstats
/proc/27129/smaps
/proc/27129/attr
/proc/27129/attr/current
/proc/27129/attr/prev
/proc/27129/attr/exec
/proc/27129/attr/fscreate
/proc/27129/attr/keycreate
/proc/27129/attr/sockcreate
/proc/27129/wchan
/proc/27129/schedstat
/proc/27129/cpuset
/proc/27129/oom_score
/proc/27129/oom_adj
/proc/27129/loginuid
/proc/27129/limits
/proc/27129/limits
/proc/27129/coredump_filter
/proc/27244
/proc/27244/task
/proc/27244/task/27244
/proc/27244/task/27244/attr
/proc/27244/attr
/proc/27245
/proc/27245/task
/proc/27245/task/27245
/proc/27245/task/27245/fd
/proc/27245/task/27245/fd/0
/proc/27245/task/27245/fd/1
/proc/27245/task/27245/fd/2
/proc/27245/task/27245/fd/255
/proc/27245/task/27245/environ
/proc/27245/task/27245/auxv
/proc/27245/task/27245/status
/proc/27245/task/27245/cmdline
/proc/27245/task/27245/stat
/proc/27245/task/27245/statm
/proc/27245/task/27245/maps
/proc/27245/task/27245/mem
/proc/27245/task/27245/cwd
/proc/27245/task/27245/root
/proc/27245/task/27245/exe
/proc/27245/task/27245/mounts
/proc/27245/task/27245/smaps
/proc/27245/task/27245/attr
/proc/27245/task/27245/attr/current
/proc/27245/task/27245/attr/prev
/proc/27245/task/27245/attr/exec
/proc/27245/task/27245/attr/fscreate
/proc/27245/task/27245/attr/keycreate
/proc/27245/task/27245/attr/sockcreate
/proc/27245/task/27245/wchan
/proc/27245/task/27245/schedstat
/proc/27245/task/27245/cpuset
/proc/27245/task/27245/oom_score
/proc/27245/task/27245/oom_adj
/proc/27245/task/27245/loginuid
/proc/27245/task/27245/limits
/proc/27245/task/27245/limits
/proc/27245/fd
/proc/27245/fd/0
/proc/27245/fd/1
/proc/27245/fd/2
/proc/27245/fd/255
/proc/27245/environ
/proc/27245/auxv
/proc/27245/status
/proc/27245/cmdline
/proc/27245/stat
/proc/27245/statm
/proc/27245/maps
/proc/27245/mem
/proc/27245/cwd
/proc/27245/root
/proc/27245/exe
/proc/27245/mounts
/proc/27245/mountstats
/proc/27245/smaps
/proc/27245/attr
/proc/27245/attr/current
/proc/27245/attr/prev
/proc/27245/attr/exec
/proc/27245/attr/fscreate
/proc/27245/attr/keycreate
/proc/27245/attr/sockcreate
/proc/27245/wchan
/proc/27245/schedstat
/proc/27245/cpuset
/proc/27245/oom_score
/proc/27245/oom_adj
/proc/27245/loginuid
/proc/27245/limits
/proc/27245/limits
/proc/27245/coredump_filter
/proc/27280
/proc/27280/task
/proc/27280/task/27280
/proc/27280/task/27280/fd
/proc/27280/task/27280/fd/0
/proc/27280/task/27280/fd/1
/proc/27280/task/27280/fd/2
/proc/27280/task/27280/fd/3
/proc/27280/task/27280/environ
/proc/27280/task/27280/auxv
/proc/27280/task/27280/status
/proc/27280/task/27280/cmdline
/proc/27280/task/27280/stat
/proc/27280/task/27280/statm
/proc/27280/task/27280/maps
/proc/27280/task/27280/mem
/proc/27280/task/27280/cwd
/proc/27280/task/27280/root
/proc/27280/task/27280/exe
/proc/27280/task/27280/mounts
/proc/27280/task/27280/smaps
/proc/27280/task/27280/attr
/proc/27280/task/27280/attr/current
/proc/27280/task/27280/attr/prev
/proc/27280/task/27280/attr/exec
/proc/27280/task/27280/attr/fscreate
/proc/27280/task/27280/attr/keycreate
/proc/27280/task/27280/attr/sockcreate
/proc/27280/task/27280/wchan
/proc/27280/task/27280/schedstat
/proc/27280/task/27280/cpuset
/proc/27280/task/27280/oom_score
/proc/27280/task/27280/oom_adj
/proc/27280/task/27280/loginuid
/proc/27280/task/27280/limits
/proc/27280/task/27280/limits
/proc/27280/fd
/proc/27280/fd/0
/proc/27280/fd/1
/proc/27280/fd/2
/proc/27280/fd/3
/proc/27280/environ
/proc/27280/auxv
/proc/27280/status
/proc/27280/cmdline
/proc/27280/stat
/proc/27280/statm
/proc/27280/maps
/proc/27280/mem
/proc/27280/cwd
/proc/27280/root
/proc/27280/exe
/proc/27280/mounts
/proc/27280/mountstats
/proc/27280/smaps
/proc/27280/attr
/proc/27280/attr/current
/proc/27280/attr/prev
/proc/27280/attr/exec
/proc/27280/attr/fscreate
/proc/27280/attr/keycreate
/proc/27280/attr/sockcreate
/proc/27280/wchan
/proc/27280/schedstat
/proc/27280/cpuset
/proc/27280/oom_score
/proc/27280/oom_adj
/proc/27280/loginuid
/proc/27280/limits
/proc/27280/limits
/proc/27280/coredump_filter
[/code]
Now look at the output of ps -e from the other session which show all the processes the kernel is processing:
[code]/home/cis90/roddyduk $ ps -e
PID TTY TIME CMD
1 ? 00:00:04 init
2 ? 00:00:00 migration/0
3 ? 00:00:00 ksoftirqd/0
4 ? 00:00:00 watchdog/0
5 ? 00:00:01 migration/1
6 ? 00:00:00 ksoftirqd/1
7 ? 00:00:00 watchdog/1
8 ? 00:00:00 events/0
9 ? 00:00:00 events/1
10 ? 00:00:00 khelper
11 ? 00:00:00 kthread
15 ? 00:00:00 kblockd/0
16 ? 00:00:00 kblockd/1
17 ? 00:00:00 kacpid
109 ? 00:00:00 cqueue/0
110 ? 00:00:00 cqueue/1
113 ? 00:00:00 khubd
115 ? 00:00:00 kseriod
181 ? 00:00:00 pdflush
182 ? 00:00:04 pdflush
183 ? 00:00:00 kswapd0
184 ? 00:00:00 aio/0
185 ? 00:00:00 aio/1
341 ? 00:00:00 kpsmoused
371 ? 00:00:00 ata/0
372 ? 00:00:00 ata/1
373 ? 00:00:00 ata_aux
377 ? 00:00:00 scsi_eh_0
378 ? 00:00:00 scsi_eh_1
379 ? 00:01:02 kjournald
412 ? 00:00:00 kauditd
446 ? 00:00:00 udevd
869 ? 00:00:00 kedac
1420 ? 00:00:00 kmpathd/0
1421 ? 00:00:00 kmpathd/1
2082 ? 00:00:05 restorecond
2098 ? 00:00:08 auditd
2100 ? 00:00:04 audispd
2120 ? 00:00:17 syslogd
2123 ? 00:00:00 klogd
2160 ? 00:00:17 mcstransd
2183 ? 00:00:00 portmap
2201 ? 00:01:00 setroubleshootd
2227 ? 00:00:00 rpc.statd
2275 ? 00:00:00 rpc.idmapd
2345 ? 00:00:00 vmnet-bridge
2364 ? 00:00:00 vmnet-natd
2383 ? 00:00:13 dbus-daemon
2434 ? 00:00:50 pcscd
2472 ? 00:00:00 hidd
2493 ? 00:00:01 automount
2518 ? 00:00:00 acpid
2534 ? 00:00:00 hpiod
2539 ? 00:00:00 python
2556 ? 00:00:00 cupsd
2575 ? 00:00:08 sshd
2600 ? 00:00:00 sendmail
2609 ? 00:00:00 sendmail
2626 ? 00:00:00 crond
2662 ? 00:00:00 xfs
2693 ? 00:00:00 atd
2710 ? 00:00:00 rhnsd
2743 ? 00:01:16 yum-updatesd
2745 ? 00:00:00 gam_server
2749 ? 00:00:00 vmnet-netifup
2758 ? 00:00:00 vmnet-netifup
2768 ? 00:00:00 vmnet-netifup
2827 ? 00:00:00 vmnet-dhcpd
2858 ? 00:00:00 vmnet-dhcpd
2859 ? 00:00:00 vmnet-dhcpd
2875 ? 00:00:01 hald
2876 ? 00:00:00 hald-runner
2883 ? 00:00:00 hald-addon-acpi
2886 ? 00:00:00 hald-addon-keyb
2890 ? 00:00:00 hald-addon-keyb
2898 ? 00:02:21 hald-addon-stor
2944 ? 00:00:00 smartd
2949 tty2 00:00:00 mingetty
2950 tty3 00:00:00 mingetty
12891 ? 00:00:00 screen
12892 pts/3 00:00:00 bash
26444 ? 00:00:00 sshd
26446 ? 00:00:00 sshd
26447 pts/0 00:00:00 bash
27125 ? 00:00:00 sshd
27128 ? 00:00:00 sshd
27129 pts/2 00:00:00 bash
27195 ? 00:00:00 sshd
27199 ? 00:00:00 sshd
27200 pts/1 00:00:00 bash
27242 ? 00:00:00 sshd
27244 ? 00:00:00 sshd
27245 pts/4 00:00:00 bash
27280 pts/2 00:00:00 find
27281 pts/4 00:00:00 ps
29218 tty1 00:00:00 mingetty
/home/cis90/roddyduk $
[/code]
By comparing the two outputs you will see that the numerical directories in /proc correspond to PIDs (Process IDs) shown in the ps output. 27280 is the find command process. PIDs 27245 and 27129 are the bash processes on pts/4 and pts/2. PID 27128 is the SSH daemon used by Putty. We will start looking at processes in a later lesson but it is kind of neat to see them at play here. This is what happens when we load a command into the "little box" I show in the slides and it becomes a process handled by the kernel.
- Rich