IMPORTANT: Per accedir als fitxer de subversion: http://acacha.org/svn (sense password). Poc a poc s'aniran migrant els enllaços. Encara però funciona el subversion de la farga però no se sap fins quan... (usuari: prova i la paraula de pas 123456)

Processos del sistema

A la carpeta proc, hi ha una carpeta per cada procés del sistema:

$ ps
PID TTY          TIME CMD
508 pts/5    00:00:00 ps
32470 pts/5    00:00:00 bash

$ ls /proc/32470/
attr  clear_refs  cpuset  environ  fd      maps  mounts      oom_adj    root     smaps  statm   task
auxv  cmdline     cwd     exe      fdinfo  mem   mountstats  oom_score  seccomp  stat   status  wchan

La carpeta proc conté informació de només lectura del kernel (nucli del sistema operatiu). La informació del processos la trobem en aquestes carpetes

Per exemple la llista dels descriptors de fitxer (fd) que utilitza un procés es pot obtenir amb:

$ sudo ls -la /proc/32470/fd/
total 0
dr-x------ 2 sergi sergi  0 2008-05-01 13:18 .
dr-xr-xr-x 6 sergi sergi  0 2008-05-01 13:18 ..
lrwx------ 1 sergi sergi 64 2008-05-01 13:24 0 -> /dev/pts/5
lrwx------ 1 sergi sergi 64 2008-05-01 13:24 1 -> /dev/pts/5
lrwx------ 1 sergi sergi 64 2008-05-01 13:19 2 -> /dev/pts/5
lrwx------ 1 sergi sergi 64 2008-05-01 13:24 255 -> /dev/pts/5

Fitxers d'un procés a la carpeta proc

Tota la informació d'un procés esta emmagatzemada a la carpeta proc:

$ sudo ls -ls /proc/2948
total 0
0 dr-xr-xr-x 2 root root 0 2008-10-25 11:12 attr
0 -r-------- 1 root root 0 2008-10-25 11:12 auxv
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 cgroup
0 --w------- 1 root root 0 2008-10-25 11:12 clear_refs
0 -r--r--r-- 1 root root 0 2008-10-25 09:41 cmdline
0 -rw-r--r-- 1 root root 0 2008-10-25 11:12 coredump_filter
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 cpuset
0 lrwxrwxrwx 1 root root 0 2008-10-25 11:12 cwd -> /
0 -r-------- 1 root root 0 2008-10-25 11:12 environ
0 lrwxrwxrwx 1 root root 0 2008-10-25 09:41 exe -> /sbin/udevd
0 dr-x------ 2 root root 0 2008-10-25 11:12 fd
0 dr-x------ 2 root root 0 2008-10-25 11:12 fdinfo
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 io
0 -r-------- 1 root root 0 2008-10-25 11:12 limits
0 -rw-r--r-- 1 root root 0 2008-10-25 11:12 loginuid
0 -r--r--r-- 1 root root 0 2008-10-25 10:16 maps
0 -rw------- 1 root root 0 2008-10-25 11:12 mem
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 mounts
0 -r-------- 1 root root 0 2008-10-25 11:12 mountstats
0 -rw-r--r-- 1 root root 0 2008-10-25 09:41 oom_adj
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 oom_score
0 lrwxrwxrwx 1 root root 0 2008-10-25 11:12 root -> /
0 -rw-r--r-- 1 root root 0 2008-10-25 11:12 sched
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 smaps
0 -r--r--r-- 1 root root 0 2008-10-25 09:41 stat
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 statm
0 -r--r--r-- 1 root root 0 2008-10-25 09:41 status
0 dr-xr-xr-x 3 root root 0 2008-10-25 11:12 task
0 -r--r--r-- 1 root root 0 2008-10-25 11:12 wchan 

attr

Attr és una carpeta i no pas un fitxer

$ ps aux | grep bash
sergi    10589  0.0  0.1   6112  3496 pts/0    Ss+  10:02   0:00 bash

Podeu obtenir el PID de la primera bash que heu executat amb:

$ ps aux | grep bash |  awk '{print $2}' | head -n 1
$ ls -l /proc/10589/attr/
total 0
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 current
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 exec
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 fscreate
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 keycreate
-r--r--r-- 1 sergi sergi 0 2008-10-25 11:20 prev
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 sockcreate

O alternativament:

$ ls -l /proc/`ps aux | grep bash |  awk '{print $2}' | head -n 1`/attr
total 0
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 current
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 exec
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 fscreate
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 keycreate
-r--r--r-- 1 sergi sergi 0 2008-10-25 11:20 prev
-rw-rw-rw- 1 sergi sergi 0 2008-10-25 11:20 sockcreate
NOTA: Les comes ``, s'obtenen amb l'accent obert (premeu dos vegades la combinació la tecla `)

cgroup

cmdline

Mostra la comanda que ha executat aquest procés:

$ cat cmdline
bash

cpuset

environ

Mostra les variables d'entorn del procés:

$ cat environ 
GNOME_KEYRING_SOCKET=/tmp/keyring-MtjzcS 

/socketLOGNAME=sergiGDMSESSION=defaultGDM_XSERVER_LOCATION=localGNOME_DESKTOP_SESSION_ID=DefaultTERM=xtermGNOME_KEYRING_PID=7854USERNAME=sergiXAUTHORITY=/home/sergi/.XauthorityGPG_AGENT_INFO=/tmp/seahorse-BYkfFo/S.gpg-agent:7950:1USER=sergiDESKTOP_STARTUP_ID=SSH_AUTH_SOCK=/tmp/keyring-MtjzcS/sshDBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-KUpTqooMVx,guid=3d604e0c0618f85acb47ccad4902ce19XDG_SESSION_COOKIE=5bc805d6540f209e1d0dee00485875f6-1224920598.877820-1803587638PWD=/home/sergiWINDOWID=62914652SHELL=/bin/bashSESSION_MANAGER=local/dell-desktop:/tmp/.ICE-unix/7855HOME=/home/sergiDISPLAY=:0.0LANG=ca_ES.UTF-8DESKTOP_SESSION=defaultWINDOWPATH=7GDM_LANG=ca_ES.UTF-8PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesCOLORTERM=gnome-terminalGTK_RC_FILES=/etc/gtk/gtkrc:/home/sergi/.gtkrc- 1.2-gnome2XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/

fd

io

Informació d'entrada i sortida:

$ cat io 
rchar: 301406
wchar: 7230
syscr: 1079
syscw: 465
read_bytes: 364544
write_bytes: 0
cancelled_write_bytes: 0

loginuid

mem

mountstats

Sistemes de fitxers muntats:

$ cat mountstats 
device rootfs mounted on / with fstype rootfs
device none mounted on /sys with fstype sysfs
device none mounted on /proc with fstype proc
device udev mounted on /dev with fstype tmpfs
device fusectl mounted on /sys/fs/fuse/connections with fstype fusectl
device /dev/disk/by-uuid/d93d0894-8870-45be-aabf-93b88903098a mounted on / with fstype ext3
device /dev/disk/by-uuid/d93d0894-8870-45be-aabf-93b88903098a mounted on /dev/.static/dev with fstype ext3
device tmpfs mounted on /var/run with fstype tmpfs
device tmpfs mounted on /var/lock with fstype tmpfs
device usbfs mounted on /proc/bus/usb with fstype usbfs
device tmpfs mounted on /lib/modules/2.6.24-19-generic/volatile with fstype tmpfs
device tmpfs mounted on /dev/shm with fstype tmpfs
device devpts mounted on /dev/pts with fstype devpts
device usbfs mounted on /dev/bus/usb/.usbfs with fstype usbfs
device udev mounted on /proc/bus/usb with fstype tmpfs
device usbfs mounted on /proc/bus/usb/.usbfs with fstype usbfs
device tmpfs mounted on /var/run with fstype tmpfs
device tmpfs mounted on /var/lock with fstype tmpfs
device none mounted on /proc/bus/usb with fstype usbfs
device securityfs mounted on /sys/kernel/security with fstype securityfs
device binfmt_misc mounted on /proc/sys/fs/binfmt_misc with fstype binfmt_misc
device gvfs-fuse-daemon mounted on /home/sergi/.gvfs with fstype fuse
device nfsd mounted on /proc/fs/nfsd with fstype nfsd

oom_score

sched

Informació del planificador de processos (scheduler):

$ cat sched 
bash (10589, #threads: 1)
---------------------------------------------------------
se.exec_start                      :       9991684.021173
se.vruntime                        :       2325870.030730
se.sum_exec_runtime                :           181.877586
nr_switches                        :                  494
nr_voluntary_switches              :                  387
nr_involuntary_switches            :                  107
se.load.weight                     :                 1024
policy                             :                    0
prio                               :                  120
clock-delta                        :                  102

stat

status

$ cat status 
Name:	bash
State:	S (sleeping)
Tgid:	10589
Pid:	10589
PPid:	10585
TracerPid:	0
Uid:	1001	1001	1001	1001
Gid:	1001	1001	1001	1001
FDSize:	256
Groups:	4 20 21 24 25 26 29 30 44 46 104 106 110 127 131 1001 1003 
VmPeak:	    6112 kB
VmSize:	    6112 kB
VmLck:	       0 kB
VmHWM:	    3496 kB
VmRSS:	    3496 kB
VmData:	    2260 kB
VmStk:	      84 kB
VmExe:	     668 kB
VmLib:	    1784 kB
VmPTE:	      12 kB
Threads:	1
SigQ:	0/16307
SigPnd:	0000000000000000
ShdPnd:	0000000000000000
SigBlk:	0000000000000000
SigIgn:	0000000000384004
SigCgt:	000000004b813efb
CapInh:	0000000000000000
CapPrm:	0000000000000000
CapEff:	0000000000000000
Cpus_allowed:	03
Mems_allowed:	1
voluntary_ctxt_switches:	390
nonvoluntary_ctxt_switches:	107

wchan

auxv

clear_refs

coredump_filter

cwd

exe

fdinfo

limits

maps

mounts

oom_adj

root

smaps

Mapes de memòria:

$ head smaps 
08048000-080ef000 r-xp 00000000 08:03 7372882    /bin/bash
Size:                668 kB
Rss:                 580 kB
Shared_Clean:        580 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:          580 kB
080ef000-080f5000 rw-p 000a6000 08:03 7372882    /bin/bash
Size:                 24 kB

statm

task