A process is a binary file that is loaded into memory and executed. When the file is loaded it needs the operating system to supply it with information such that it can execute correctly. Collectively, this information is refered to as the process environment and includes:
This information is stored in /proc:
[trainee@centos ~]$ cd /proc; ls -d [0-9]* 1 1340 1501 1743 1819 1924 2058 2118 2141 2385 2558 3 69 10 1373 1563 1760 1820 1934 2081 2122 2144 2387 2574 30 7 11 1377 1572 1768 1824 194 2089 2123 2146 24 26 31 8 1167 1392 16 1776 1827 1944 2094 2127 2149 241 2622 332 898 12 14 161 1787 1837 1952 21 2128 2198 242 2623 36 899 1209 1417 163 1799 1839 1953 2100 2129 22 2427 2624 38 9 13 1426 1647 18 1857 2 2106 2130 2214 2466 2657 39 999 1304 1427 1655 1807 1863 20 2107 2131 2216 2467 27 4 1315 1458 17 1812 19 2038 2110 2132 2217 2476 2767 479 1319 1481 1736 1814 1912 2047 2111 2133 23 25 28 5 1338 15 1742 1818 1918 2052 2113 2137 2383 251 29 6
Each directory has as a name the PID of the process it refers to. Looking into one of the directories, you can see the process environment information:
[trainee@centos proc]$ su - Password: [root@centos 1]# cd /proc/1 ; ls -l total 0 dr-xr-xr-x. 2 root root 0 Dec 4 12:58 attr -rw-r--r--. 1 root root 0 Dec 4 12:58 autogroup -r--------. 1 root root 0 Dec 4 12:58 auxv -r--r--r--. 1 root root 0 Dec 4 12:58 cgroup --w-------. 1 root root 0 Dec 4 12:58 clear_refs -r--r--r--. 1 root root 0 Dec 4 12:05 cmdline -rw-r--r--. 1 root root 0 Dec 4 12:58 coredump_filter -r--r--r--. 1 root root 0 Dec 4 12:58 cpuset lrwxrwxrwx. 1 root root 0 Dec 4 12:58 cwd -> / -r--------. 1 root root 0 Dec 4 12:58 environ lrwxrwxrwx. 1 root root 0 Dec 4 12:05 exe -> /sbin/init dr-x------. 2 root root 0 Dec 4 12:05 fd dr-x------. 2 root root 0 Dec 4 12:58 fdinfo -r--------. 1 root root 0 Dec 4 12:58 io -rw-------. 1 root root 0 Dec 4 12:58 limits -rw-r--r--. 1 root root 0 Dec 4 12:58 loginuid -r--r--r--. 1 root root 0 Dec 4 12:58 maps -rw-------. 1 root root 0 Dec 4 12:58 mem -r--r--r--. 1 root root 0 Dec 4 12:58 mountinfo -r--r--r--. 1 root root 0 Dec 4 12:58 mounts -r--------. 1 root root 0 Dec 4 12:58 mountstats dr-xr-xr-x. 7 root root 0 Dec 4 12:58 net -rw-r--r--. 1 root root 0 Dec 4 12:58 oom_adj -r--r--r--. 1 root root 0 Dec 4 12:58 oom_score -rw-r--r--. 1 root root 0 Dec 4 12:58 oom_score_adj -r--r--r--. 1 root root 0 Dec 4 12:58 pagemap -r--r--r--. 1 root root 0 Dec 4 12:58 personality lrwxrwxrwx. 1 root root 0 Dec 4 12:58 root -> / -rw-r--r--. 1 root root 0 Dec 4 12:58 sched -r--r--r--. 1 root root 0 Dec 4 12:58 schedstat -r--r--r--. 1 root root 0 Dec 4 12:58 sessionid -r--r--r--. 1 root root 0 Dec 4 12:58 smaps -r--r--r--. 1 root root 0 Dec 4 12:58 stack -r--r--r--. 1 root root 0 Dec 4 12:05 stat -r--r--r--. 1 root root 0 Dec 4 12:58 statm -r--r--r--. 1 root root 0 Dec 4 12:06 status -r--r--r--. 1 root root 0 Dec 4 12:58 syscall dr-xr-xr-x. 3 root root 0 Dec 4 12:58 task -r--r--r--. 1 root root 0 Dec 4 12:58 wchan
<note important> Note that the content of the files is of no use to a System Administrator so just cd to /root before continuing further. </note>
There are three types of processes:
A process can be in any one of 9 process states:
The output from this command shows the processes attached to the current terminal:
[root@centos 1]# cd ~ [root@centos ~]# ps PID TTY TIME CMD 3159 pts/0 00:00:00 su 3167 pts/0 00:00:00 bash 3337 pts/0 00:00:00 ps
You can get more details by using the -l switch:
[root@centos ~]# ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 3159 2624 0 80 0 - 2133 - pts/0 00:00:00 su 4 S 0 3167 3159 0 80 0 - 1282 - pts/0 00:00:00 bash 4 R 0 3343 3167 2 80 0 - 1219 - pts/0 00:00:00 ps
This output shows some usefull information:
F | Process flag. The value of 4 means the process is using root privileges. |
---|---|
S | The process state - S (sleeping), R (In run queue), Z (zombie), N (low priority), D (uninterruptible sleep), T (Traced) |
UID | User ID of the user who has stated the process |
PID | Process ID |
PPID | Parent PID |
PRI | Process priority |
NI | Process nice value |
TTY | Name of the terminal in which the process was started |
TIME | Processing time |
CMD | The command that generated the process |
To see the process table, use the l and x switches:
[root@centos ~]# ps lx F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND 4 0 1 0 20 0 2900 1432 - Ss ? 0:02 /sbin/init 1 0 2 0 20 0 0 0 - S ? 0:00 [kthreadd] 1 0 3 2 -100 - 0 0 - S ? 0:00 [migration] 1 0 4 2 20 0 0 0 - S ? 0:02 [ksoftirqd] 1 0 5 2 -100 - 0 0 - S ? 0:00 [migration] 5 0 6 2 -100 - 0 0 - S ? 0:00 [watchdog/] 1 0 7 2 20 0 0 0 - S ? 0:15 [events/0] 1 0 8 2 20 0 0 0 - S ? 0:00 [cgroup] 1 0 9 2 20 0 0 0 - S ? 0:00 [khelper] 1 0 10 2 20 0 0 0 - S ? 0:00 [netns] 1 0 11 2 20 0 0 0 - S ? 0:00 [async/mgr] 1 0 12 2 20 0 0 0 - S ? 0:00 [pm] 1 0 13 2 20 0 0 0 - S ? 0:00 [sync_supe] 1 0 14 2 20 0 0 0 - S ? 0:00 [bdi-defau] 1 0 15 2 20 0 0 0 - S ? 0:00 [kintegrit] 1 0 16 2 20 0 0 0 - S ? 0:03 [kblockd/0] 1 0 17 2 20 0 0 0 - S ? 0:00 [kacpid] 1 0 18 2 20 0 0 0 - S ? 0:00 [kacpi_not] 1 0 19 2 20 0 0 0 - S ? 0:00 [kacpi_hot] 1 0 20 2 20 0 0 0 - S ? 0:19 [ata/0] 1 0 21 2 20 0 0 0 - S ? 0:00 [ata_aux] 1 0 22 2 20 0 0 0 - S ? 0:00 [ksuspend_] 1 0 23 2 20 0 0 0 - S ? 0:00 [khubd] 5 0 24 2 20 0 0 0 - S ? 0:00 [kseriod] 1 0 25 2 20 0 0 0 - S ? 0:00 [md/0] 1 0 26 2 20 0 0 0 - S ? 0:00 [md_misc/0] 1 0 27 2 20 0 0 0 - S ? 0:00 [khungtask] 1 0 28 2 20 0 0 0 - S ? 0:00 [kswapd0] 1 0 29 2 25 5 0 0 - SN ? 0:00 [ksmd] 1 0 30 2 20 0 0 0 - S ? 0:00 [aio/0] 1 0 31 2 20 0 0 0 - S ? 0:00 [crypto/0] 1 0 36 2 20 0 0 0 - S ? 0:00 [kthrotld/] 1 0 38 2 20 0 0 0 - S ? 0:00 [kpsmoused] 1 0 39 2 20 0 0 0 - S ? 0:00 [usbhid_re] 1 0 69 2 20 0 0 0 - S ? 0:00 [kstriped] 1 0 161 2 20 0 0 0 - S ? 0:00 [scsi_eh_0] 1 0 163 2 20 0 0 0 - S ? 0:17 [scsi_eh_1] 1 0 194 2 20 0 0 0 - S ? 0:00 [scsi_eh_2] 1 0 241 2 20 0 0 0 - S ? 0:01 [jbd2/sda2] 1 0 242 2 20 0 0 0 - S ? 0:00 [ext4-dio-] 1 0 251 2 20 0 0 0 - S ? 0:01 [flush-8:0] 5 0 332 1 16 -4 2864 1140 - S<s ? 0:00 /sbin/udevd 1 0 479 2 20 0 0 0 - S ? 0:00 [iprt/0] 1 0 898 2 20 0 0 0 - S ? 0:00 [jbd2/sda1] 1 0 899 2 20 0 0 0 - S ? 0:00 [ext4-dio-] 1 0 999 2 20 0 0 0 - S ? 0:00 [kauditd] 5 0 1167 1 20 0 35976 1492 - Sl ? 0:00 /sbin/rsysl 5 0 1315 1 20 0 20152 4060 - Ssl ? 0:00 NetworkMana 4 0 1319 1 20 0 4592 2136 - S ? 0:00 /usr/sbin/m 1 0 1340 1 20 0 7312 632 - Ss ? 0:00 /usr/sbin/w 1 0 1373 2 20 0 0 0 - S ? 0:00 [rpciod/0] 1 0 1377 1 20 0 3532 496 - Ss ? 0:00 rpc.idmapd 4 0 1392 1 20 0 12100 2896 - Ss ? 0:00 cupsd -C /e 1 0 1417 1 20 0 2020 588 - Ss ? 0:00 /usr/sbin/a 0 0 1427 1426 20 0 3784 1108 - S ? 0:00 hald-runner 0 0 1458 1427 20 0 3860 1140 - S ? 0:50 hald-addon- 5 0 1501 1 20 0 28984 1584 - Ssl ? 0:01 automount - 1 0 1563 1 20 0 11912 1408 - Sl ? 0:27 /usr/sbin/V 4 0 1572 1 20 0 21972 2848 - Sl ? 0:07 /usr/sbin/c 5 0 1647 1 20 0 8640 980 - Ss ? 0:00 /usr/sbin/s 4 0 1736 1 20 0 13192 2664 - Ss ? 0:00 /usr/libexe 1 0 1760 1 20 0 5168 828 - Ss ? 0:00 /usr/sbin/a 0 0 1768 1 20 0 5100 804 - Ss ? 0:00 abrt-dump-o 5 0 1776 1 20 0 5956 1280 - Ss ? 0:04 crond 5 0 1787 1 20 0 2944 492 - Ss ? 0:00 /usr/sbin/a 1 0 1799 1 20 0 8476 560 - Ss ? 0:00 /usr/sbin/c 4 0 1807 1 20 0 6108 2004 - Ss ? 0:00 /usr/sbin/g 4 0 1812 1 20 0 2008 476 - Ss+ tty2 0:00 /sbin/minge 4 0 1814 1 20 0 2008 476 - Ss+ tty3 0:00 /sbin/minge 4 0 1818 1 20 0 2008 480 - Ss+ tty4 0:00 /sbin/minge 5 0 1819 332 18 -2 3520 1956 - S< ? 0:00 /sbin/udevd 5 0 1820 332 18 -2 3520 1960 - S< ? 0:00 /sbin/udevd 4 0 1824 1 20 0 2008 472 - Ss+ tty5 0:00 /sbin/minge 4 0 1827 1 20 0 2008 476 - Ss+ tty6 0:00 /sbin/minge 4 0 1837 1807 20 0 9928 3148 - S ? 0:00 /usr/libexe 4 0 1839 1837 20 0 53952 39864 - Rs+ tty1 4:14 /usr/bin/Xo 4 0 1863 1 20 0 5848 2560 - S ? 0:00 /usr/libexe 4 0 1912 1 20 0 6632 3604 - S ? 0:00 /usr/libexe 4 0 1924 1837 20 0 8380 2840 - S ? 0:00 pam: gdm-pa 4 0 2127 1 20 0 5780 2556 - S ? 0:00 /usr/libexe 1 0 2132 2127 20 0 5568 536 - S ? 0:17 udisks-daem 4 0 2387 1315 20 0 2836 1276 - S ? 0:00 /sbin/dhcli 4 0 3159 2624 20 0 8532 3608 - S pts/0 0:00 su - 4 0 3167 3159 20 0 5128 1660 - S pts/0 0:00 -bash 4 0 4646 3167 20 0 4876 904 - R+ pts/0 0:00 ps lx
This output provides further usefull information:
RSS | Memory in KB used by the process |
---|
Using the a, u and x switches you obtain the following output:
[root@centos ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2900 1432 ? Ss 12:05 0:02 /sbin/init root 2 0.0 0.0 0 0 ? S 12:05 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 12:05 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S 12:05 0:02 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 12:05 0:00 [migration/0] root 6 0.0 0.0 0 0 ? S 12:05 0:00 [watchdog/0] root 7 0.1 0.0 0 0 ? S 12:05 0:16 [events/0] root 8 0.0 0.0 0 0 ? S 12:05 0:00 [cgroup] root 9 0.0 0.0 0 0 ? S 12:05 0:00 [khelper] root 10 0.0 0.0 0 0 ? S 12:05 0:00 [netns] root 11 0.0 0.0 0 0 ? S 12:05 0:00 [async/mgr] root 12 0.0 0.0 0 0 ? S 12:05 0:00 [pm] root 13 0.0 0.0 0 0 ? S 12:05 0:00 [sync_supers] root 14 0.0 0.0 0 0 ? S 12:05 0:00 [bdi-default] root 15 0.0 0.0 0 0 ? S 12:05 0:00 [kintegrityd/0] root 16 0.0 0.0 0 0 ? S 12:05 0:03 [kblockd/0] root 17 0.0 0.0 0 0 ? S 12:05 0:00 [kacpid] root 18 0.0 0.0 0 0 ? S 12:05 0:00 [kacpi_notify] root 19 0.0 0.0 0 0 ? S 12:05 0:00 [kacpi_hotplug] root 20 0.1 0.0 0 0 ? S 12:05 0:20 [ata/0] root 21 0.0 0.0 0 0 ? S 12:05 0:00 [ata_aux] root 22 0.0 0.0 0 0 ? S 12:05 0:00 [ksuspend_usbd] root 23 0.0 0.0 0 0 ? S 12:05 0:00 [khubd] root 24 0.0 0.0 0 0 ? S 12:05 0:00 [kseriod] root 25 0.0 0.0 0 0 ? S 12:05 0:00 [md/0] root 26 0.0 0.0 0 0 ? S 12:05 0:00 [md_misc/0] root 27 0.0 0.0 0 0 ? S 12:05 0:00 [khungtaskd] root 28 0.0 0.0 0 0 ? S 12:05 0:00 [kswapd0] root 29 0.0 0.0 0 0 ? SN 12:05 0:00 [ksmd] root 30 0.0 0.0 0 0 ? S 12:05 0:00 [aio/0] root 31 0.0 0.0 0 0 ? S 12:05 0:00 [crypto/0] root 36 0.0 0.0 0 0 ? S 12:05 0:00 [kthrotld/0] root 38 0.0 0.0 0 0 ? S 12:05 0:00 [kpsmoused] root 39 0.0 0.0 0 0 ? S 12:05 0:00 [usbhid_resume] root 69 0.0 0.0 0 0 ? S 12:05 0:00 [kstriped] root 161 0.0 0.0 0 0 ? S 12:05 0:00 [scsi_eh_0] root 163 0.1 0.0 0 0 ? S 12:05 0:17 [scsi_eh_1] root 194 0.0 0.0 0 0 ? S 12:05 0:00 [scsi_eh_2] root 241 0.0 0.0 0 0 ? S 12:05 0:01 [jbd2/sda2-8] root 242 0.0 0.0 0 0 ? S 12:05 0:00 [ext4-dio-unwr] root 251 0.0 0.0 0 0 ? S 12:05 0:01 [flush-8:0] root 332 0.0 0.0 2864 1140 ? S<s 12:05 0:00 /sbin/udevd -d root 479 0.0 0.0 0 0 ? S 12:05 0:00 [iprt/0] root 898 0.0 0.0 0 0 ? S 12:06 0:00 [jbd2/sda1-8] root 899 0.0 0.0 0 0 ? S 12:06 0:00 [ext4-dio-unwr] root 999 0.0 0.0 0 0 ? S 12:06 0:00 [kauditd] root 1167 0.0 0.0 35976 1492 ? Sl 12:06 0:00 /sbin/rsyslogd rpc 1209 0.0 0.0 2576 848 ? Ss 12:06 0:00 rpcbind dbus 1304 0.1 0.1 13776 1748 ? Ssl 12:06 0:16 dbus-daemon --s root 1315 0.0 0.2 20152 4060 ? Ssl 12:06 0:00 NetworkManager root 1319 0.0 0.1 4592 2136 ? S 12:06 0:00 /usr/sbin/modem rpcuser 1338 0.0 0.0 2840 1252 ? Ss 12:06 0:00 rpc.statd root 1340 0.0 0.0 7312 632 ? Ss 12:06 0:00 /usr/sbin/wpa_s root 1373 0.0 0.0 0 0 ? S 12:06 0:00 [rpciod/0] root 1377 0.0 0.0 3532 496 ? Ss 12:06 0:00 rpc.idmapd root 1392 0.0 0.1 12100 2896 ? Ss 12:06 0:00 cupsd -C /etc/c root 1417 0.0 0.0 2020 588 ? Ss 12:06 0:00 /usr/sbin/acpid 68 1426 0.0 0.2 6820 4284 ? Ss 12:06 0:03 hald root 1427 0.0 0.0 3784 1108 ? S 12:06 0:00 hald-runner root 1458 0.4 0.0 3860 1140 ? S 12:06 0:53 hald-addon-inpu 68 1481 0.0 0.0 3504 1012 ? S 12:06 0:00 hald-addon-acpi root 1501 0.0 0.0 28984 1584 ? Ssl 12:06 0:01 automount --pid root 1563 0.2 0.0 11912 1408 ? Sl 12:06 0:28 /usr/sbin/VBoxS root 1572 0.0 0.1 21972 2848 ? Sl 12:06 0:08 /usr/sbin/conso root 1647 0.0 0.0 8640 980 ? Ss 12:06 0:00 /usr/sbin/sshd ntp 1655 0.0 0.0 5140 1432 ? Ss 12:06 0:00 ntpd -u ntp:ntp root 1736 0.0 0.1 13192 2664 ? Ss 12:06 0:00 /usr/libexec/po postfix 1743 0.0 0.1 13336 2780 ? S 12:06 0:00 qmgr -l -t fifo root 1760 0.0 0.0 5168 828 ? Ss 12:06 0:00 /usr/sbin/abrtd root 1768 0.0 0.0 5100 804 ? Ss 12:06 0:00 abrt-dump-oops root 1776 0.0 0.0 5956 1280 ? Ss 12:06 0:04 crond root 1787 0.0 0.0 2944 492 ? Ss 12:06 0:00 /usr/sbin/atd root 1799 0.0 0.0 8476 560 ? Ss 12:06 0:00 /usr/sbin/certm root 1807 0.0 0.1 6108 2004 ? Ss 12:06 0:00 /usr/sbin/gdm-b root 1812 0.0 0.0 2008 476 tty2 Ss+ 12:06 0:00 /sbin/mingetty root 1814 0.0 0.0 2008 476 tty3 Ss+ 12:06 0:00 /sbin/mingetty root 1818 0.0 0.0 2008 480 tty4 Ss+ 12:06 0:00 /sbin/mingetty root 1819 0.0 0.1 3520 1956 ? S< 12:06 0:00 /sbin/udevd -d root 1820 0.0 0.1 3520 1960 ? S< 12:06 0:00 /sbin/udevd -d root 1824 0.0 0.0 2008 472 tty5 Ss+ 12:06 0:00 /sbin/mingetty root 1827 0.0 0.0 2008 476 tty6 Ss+ 12:06 0:00 /sbin/mingetty root 1837 0.0 0.1 9928 3148 ? S 12:06 0:00 /usr/libexec/gd root 1839 2.2 2.3 53952 39632 tty1 Rs+ 12:06 4:33 /usr/bin/Xorg : gdm 1857 0.0 0.0 3628 772 ? S 12:06 0:00 /usr/bin/dbus-l root 1863 0.0 0.1 5848 2560 ? S 12:07 0:00 /usr/libexec/de root 1912 0.0 0.2 6632 3604 ? S 12:07 0:00 /usr/libexec/po rtkit 1918 0.0 0.0 25104 1152 ? SNl 12:07 0:04 /usr/libexec/rt root 1924 0.0 0.1 8380 2840 ? S 12:07 0:00 pam: gdm-passwo trainee 1934 0.0 0.2 38968 3396 ? Sl 12:07 0:00 /usr/bin/gnome- trainee 1944 0.0 0.3 30312 6480 ? Ssl 12:07 0:01 gnome-session trainee 1952 0.0 0.0 3628 640 ? S 12:07 0:00 dbus-launch --s trainee 1953 0.0 0.0 13640 1476 ? Ssl 12:07 0:00 /bin/dbus-daemo trainee 2038 0.0 0.1 8920 1800 ? Sl 12:07 0:00 /usr/bin/VBoxCl trainee 2047 0.0 0.0 8972 1564 ? Sl 12:07 0:00 /usr/bin/VBoxCl trainee 2052 0.0 0.0 7888 1196 ? Sl 12:07 0:00 /usr/bin/VBoxCl trainee 2058 1.6 0.0 9568 1520 ? Sl 12:07 3:16 /usr/bin/VBoxCl trainee 2081 0.0 0.2 7920 3532 ? S 12:07 0:01 /usr/libexec/gc trainee 2089 0.0 0.5 125348 9304 ? Ssl 12:07 0:09 /usr/libexec/gn trainee 2094 0.0 0.1 7072 2036 ? S 12:07 0:00 /usr/libexec/gv trainee 2100 0.0 0.6 101604 10964 ? Sl 12:07 0:10 metacity trainee 2106 0.0 0.2 102420 4648 ? S<sl 12:07 0:02 /usr/bin/pulsea trainee 2107 0.0 0.7 45000 13228 ? S 12:07 0:05 gnome-panel trainee 2110 0.0 0.1 11756 2776 ? S 12:07 0:00 /usr/libexec/pu trainee 2111 0.0 1.0 78928 17220 ? S 12:07 0:11 nautilus trainee 2113 0.0 0.1 41680 2884 ? Ssl 12:07 0:00 /usr/libexec/bo trainee 2118 0.0 0.7 44152 11836 ? S 12:07 0:05 /usr/libexec/wn trainee 2122 0.0 0.5 42068 9460 ? S 12:07 0:00 /usr/libexec/tr trainee 2123 0.0 0.1 7964 2848 ? S 12:07 0:00 /usr/libexec/gv root 2127 0.0 0.1 5780 2556 ? S 12:07 0:00 /usr/libexec/ud trainee 2128 0.0 0.7 56216 12348 ? S 12:07 0:00 nm-applet --sm- trainee 2129 0.0 0.1 5772 3308 ? S 12:07 0:00 /usr/sbin/resto trainee 2130 0.0 0.8 31840 14264 ? S 12:07 0:00 python /usr/sha trainee 2131 0.0 0.3 18952 5284 ? S 12:07 0:00 abrt-applet root 2132 0.1 0.0 5568 536 ? S 12:07 0:17 udisks-daemon: trainee 2133 0.0 0.3 19196 5516 ? S 12:07 0:00 /usr/libexec/po trainee 2137 0.0 0.6 106920 10432 ? S 12:07 0:00 gnome-volume-co trainee 2141 0.0 0.2 16024 3940 ? S 12:07 0:00 /usr/libexec/im trainee 2144 0.0 0.5 40896 9368 ? S 12:07 0:00 gpk-update-icon trainee 2146 0.0 0.5 36232 8712 ? S 12:07 0:02 gnome-power-man trainee 2149 0.0 0.1 7556 2720 ? S 12:07 0:00 /usr/libexec/gv trainee 2198 0.0 0.3 21076 6548 ? Ss 12:07 0:05 gnome-screensav trainee 2214 0.0 0.6 54688 10980 ? S 12:07 0:00 /usr/libexec/gd trainee 2216 0.0 0.8 47940 13516 ? S 12:07 0:02 /usr/libexec/cl trainee 2217 0.0 0.4 26464 7444 ? S 12:07 0:00 /usr/libexec/no trainee 2383 0.0 0.1 5440 2324 ? S 12:07 0:00 /usr/libexec/gc trainee 2385 0.0 0.0 6936 1616 ? S 12:07 0:00 /usr/libexec/gv root 2387 0.0 0.0 2836 1276 ? S 12:07 0:00 /sbin/dhclient trainee 2427 1.0 4.0 478060 68428 ? Sl 12:08 2:01 /opt/chromium/c trainee 2466 0.0 0.3 109476 5200 ? S 12:08 0:00 /opt/chromium/c trainee 2467 0.0 0.6 134892 11116 ? S 12:08 0:00 /opt/chromium/c trainee 2476 0.0 0.1 1069968 3200 ? S 12:08 0:00 /opt/chromium/n trainee 2558 0.0 2.1 197536 35748 ? Sl 12:08 0:02 /opt/chromium/c trainee 2574 0.4 2.7 208712 46244 ? Sl 12:08 0:54 /opt/chromium/c trainee 2622 0.1 0.7 51356 12060 ? Sl 12:09 0:16 gnome-terminal trainee 2623 0.0 0.0 2076 616 ? S 12:09 0:00 gnome-pty-helpe trainee 2624 0.0 0.0 5240 1660 pts/0 Ss 12:09 0:00 bash trainee 2657 0.0 2.2 195540 38148 ? Sl 12:10 0:06 /opt/chromium/c trainee 2767 0.8 0.9 56428 16300 ? S 12:19 1:39 gedit /home/tra root 3159 0.0 0.2 8532 3608 pts/0 S 12:59 0:00 su - root 3167 0.0 0.0 5128 1660 pts/0 S 12:59 0:00 -bash postfix 4659 0.0 0.1 13268 2648 ? S 15:26 0:00 pickup -l -t fi root 4670 5.0 0.0 4932 1044 pts/0 R+ 15:27 0:00 ps aux
This output provides further usefull information:
%CPU | % of the processor ressources used by the process |
---|---|
%MEM | % of the memory ressources used by the process |
The command line switches for the ps command are :
[root@centos ~]# ps --help ********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session OR by effective group name -e all processes -p by process ID T all processes on this terminal -s processes in the sessions given a all w/ tty, including other users -t by tty g OBSOLETE -- DO NOT USE -u by effective user ID (supports names) r only running processes U processes for specified users x processes w/o controlling ttys t by tty *********** output format ********** *********** long options *********** -o,o user-defined -f full --Group --User --pid --cols --ppid -j,j job control s signal --group --user --sid --rows --info -O,O preloaded -o v virtual memory --cumulative --format --deselect -l,l long u user-oriented --sort --tty --forest --version -F extra full X registers --heading --no-heading --context ********* misc options ********* -V,V show version L list format codes f ASCII art forest -m,m,-L,-T,H threads S children in sum -y change -l format -M,Z security data c true command name -c scheduling class -w,w wide output n numeric WCHAN,UID -H process hierarchy
This command shows the processes as a tree:
[root@centos ~]# pstree init─┬─NetworkManager─┬─dhclient │ └─{NetworkManager} ├─3*[VBoxClient───{VBoxClient}] ├─VBoxClient───2*[{VBoxClient}] ├─VBoxService───7*[{VBoxService}] ├─abrt-dump-oops ├─abrtd ├─acpid ├─atd ├─automount───4*[{automount}] ├─bonobo-activati───{bonobo-activat} ├─certmonger ├─chrome─┬─chrome │ ├─chrome─┬─3*[chrome───3*[{chrome}]] │ │ └─nacl_helper_boo │ └─22*[{chrome}] ├─clock-applet ├─console-kit-dae───63*[{console-kit-da}] ├─crond ├─cupsd ├─2*[dbus-daemon───{dbus-daemon}] ├─2*[dbus-launch] ├─devkit-power-da ├─gconf-im-settin ├─gconfd-2 ├─gdm-binary───gdm-simple-slav─┬─Xorg │ └─gdm-session-wor───gnome-session─┬─abrt-ap+ │ ├─gnome-p+ │ ├─gnome-p+ │ ├─gnome-v+ │ ├─gpk-upd+ │ ├─metacit+ │ ├─nautilus │ ├─nm-appl+ │ ├─polkit-+ │ ├─python │ ├─restore+ │ └─{gnome-+ ├─gdm-user-switch ├─gedit ├─gnome-keyring-d───2*[{gnome-keyring-}] ├─gnome-screensav ├─gnome-settings-───{gnome-settings} ├─gnome-terminal─┬─bash───su───bash───pstree │ ├─gnome-pty-helpe │ └─{gnome-terminal} ├─gvfs-gdu-volume ├─gvfsd ├─gvfsd-metadata ├─gvfsd-trash ├─hald───hald-runner─┬─hald-addon-acpi │ └─hald-addon-inpu ├─im-settings-dae ├─master─┬─pickup │ └─qmgr ├─5*[mingetty] ├─modem-manager ├─notification-ar ├─ntpd ├─polkitd ├─pulseaudio─┬─gconf-helper │ └─2*[{pulseaudio}] ├─rpc.idmapd ├─rpc.statd ├─rpcbind ├─rsyslogd───3*[{rsyslogd}] ├─rtkit-daemon───2*[{rtkit-daemon}] ├─sshd ├─trashapplet ├─udevd───2*[udevd] ├─udisks-daemon───udisks-daemon ├─wnck-applet └─wpa_supplicant
The command line switches for the pstree command are :
[root@centos ~]# pstree --help pstree: invalid option -- '-' Usage: pstree [ -a ] [ -c ] [ -h | -H PID ] [ -l ] [ -n ] [ -p ] [ -u ] [ -A | -G | -U ] [ PID | USER ] pstree -V Display a tree of processes. -a show command line arguments -A use ASCII line drawing characters -c don't compact identical subtrees -h highlight current process and its ancestors -H PID highlight this process and its ancestors -G use VT100 line drawing characters -l don't truncate long lines -n sort output by PID -p show PIDs; implies -c -u show uid transitions -U use UTF-8 (Unicode) line drawing characters -V display version information -Z show SELinux security contexts PID start at this PID; default is 1 (init) USER show only trees rooted at processes of this user
top shows a continuous real time list of running processes:
top - 15:34:10 up 3:28, 2 users, load average: 0.15, 0.19, 0.09 Tasks: 142 total, 1 running, 141 sleeping, 0 stopped, 0 zombie Cpu(s): 1.0%us, 6.9%sy, 0.0%ni, 91.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st Mem: 1670736k total, 783644k used, 887092k free, 66836k buffers Swap: 2096120k total, 0k used, 2096120k free, 444916k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1839 root 20 0 65184 38m 8900 S 3.6 2.4 5:28.94 Xorg 2622 trainee 20 0 51356 11m 9544 S 2.0 0.7 0:21.25 gnome-terminal 2058 trainee 20 0 9568 1520 1032 S 1.7 0.1 3:23.93 VBoxClient 1563 root 20 0 11912 1408 1060 S 1.0 0.1 0:29.00 VBoxService 4731 root 20 0 2704 1108 860 R 1.0 0.1 0:00.12 top 1458 root 20 0 3860 1140 1004 S 0.7 0.1 1:01.57 hald-addon-inpu 2100 trainee 20 0 99.2m 10m 9072 S 0.7 0.7 0:11.81 metacity 16 root 20 0 0 0 0 S 0.3 0.0 0:03.26 kblockd/0 20 root 20 0 0 0 0 S 0.3 0.0 0:20.65 ata/0 1 root 20 0 2900 1432 1212 S 0.0 0.1 0:02.61 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd 3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 4 root 20 0 0 0 0 S 0.0 0.0 0:02.87 ksoftirqd/0 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 6 root RT 0 0 0 0 S 0.0 0.0 0:00.81 watchdog/0 7 root 20 0 0 0 0 S 0.0 0.0 0:17.34 events/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
To see top's help, use the h key:
Help for Interactive Commands - procps version 3.2.8 Window 1:Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off. Z,B Global: 'Z' change color mappings; 'B' disable/enable bold l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info 1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode f,o . Fields/Columns: 'f' add or remove; 'o' change display order F or O . Select sort field <,> . Move sort field: '<' next col left; '>' next col right R,H . Toggle: 'R' normal/reverse sort; 'H' show threads c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time x,y . Toggle highlights: 'x' sort field; 'y' running tasks z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y') u . Show specific user only n or # . Set maximum tasks displayed k,r Manipulate tasks: 'k' kill; 'r' renice d or s Set update interval W Write configuration file q Quit ( commands shown with '.' require a visible task display window ) Press 'h' or '?' for help with Windows, any other key to continue
<note important> To return to top, use the space bar. </note>
When launched top's refresh rate is 3 seconds. To change this to 1 second, use the s key:
top - 15:38:19 up 3:32, 2 users, load average: 0.11, 0.17, 0.10 Tasks: 142 total, 2 running, 140 sleeping, 0 stopped, 0 zombie Cpu(s): 2.5%us, 9.6%sy, 0.0%ni, 86.8%id, 0.2%wa, 0.5%hi, 0.4%si, 0.0%st Mem: 1670736k total, 783924k used, 886812k free, 66940k buffers Swap: 2096120k total, 0k used, 2096120k free, 444916k cached Change delay from 3.0 to: 1 ...
To sort the list by memory usage, use the M key:
top - 15:40:11 up 3:34, 2 users, load average: 0.08, 0.14, 0.09 Tasks: 142 total, 1 running, 141 sleeping, 0 stopped, 0 zombie Cpu(s): 0.7%us, 3.7%sy, 0.0%ni, 95.3%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st Mem: 1670736k total, 783876k used, 886860k free, 66992k buffers Swap: 2096120k total, 0k used, 2096120k free, 444916k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2427 trainee 20 0 466m 66m 35m S 0.0 4.1 2:03.11 chrome 2574 trainee 20 0 203m 45m 23m S 0.0 2.8 0:54.91 chrome 1839 root 20 0 65184 38m 8900 S 1.3 2.4 5:55.25 Xorg 2657 trainee 20 0 190m 37m 22m S 0.0 2.3 0:06.44 chrome 2558 trainee 20 0 192m 34m 21m S 0.0 2.1 0:02.90 chrome 2111 trainee 20 0 78928 16m 12m S 0.0 1.0 0:12.31 nautilus 2767 trainee 20 0 56568 16m 12m S 0.0 1.0 2:15.65 gedit 2130 trainee 20 0 31840 13m 8300 S 0.0 0.9 0:00.76 python 2216 trainee 20 0 47940 13m 10m S 0.0 0.8 0:02.37 clock-applet 2107 trainee 20 0 45000 12m 10m S 0.0 0.8 0:05.98 gnome-panel 2128 trainee 20 0 56216 12m 9m S 0.0 0.7 0:00.80 nm-applet 2622 trainee 20 0 51356 11m 9544 S 0.7 0.7 0:23.92 gnome-terminal 2118 trainee 20 0 44152 11m 9692 S 0.0 0.7 0:07.06 wnck-applet 2467 trainee 20 0 131m 10m 7580 S 0.0 0.7 0:00.54 chrome 2214 trainee 20 0 54688 10m 8992 S 0.0 0.7 0:00.44 gdm-user-switch 2100 trainee 20 0 99.2m 10m 9072 S 0.0 0.7 0:12.96 metacity 2137 trainee 20 0 104m 10m 8440 S 0.0 0.6 0:00.46 gnome-volume-co
To see the processes using the processor, use the i key:
top - 15:40:53 up 3:35, 2 users, load average: 0.13, 0.15, 0.09 Tasks: 142 total, 1 running, 141 sleeping, 0 stopped, 0 zombie Cpu(s): 1.4%us, 9.3%sy, 0.0%ni, 88.0%id, 0.0%wa, 1.0%hi, 0.3%si, 0.0%st Mem: 1670736k total, 783884k used, 886852k free, 67016k buffers Swap: 2096120k total, 0k used, 2096120k free, 444912k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 4731 root 20 0 2704 1124 876 R 0.3 0.1 0:00.74 top
To leave top, use the q key.
Normally commands are executed in the foreground of a terminal. However you can also execute a command in what is know as the background :
# sleep 9999 &
<note important> A process in that foreground is synchronous whereas a process in the background is said to be asynchronous. </note>
Linux identifies processes sent to the back ground by job numbers.
The jobs command shows a list of all the current jobs associated with the current terminal:
[root@centos ~]# sleep 9999 & [1] 2716 [root@centos ~]# jobs -l [1]+ 2716 Running sleep 9999 &
<note important> The job number is between square brackets whilst the PID is not. The + sign indicates that this is the last job to have been modified. </note>
If you wish to send a job to the background to free up the current terminal, the process first has to be suspended. This can be acheived by using CtrlZ :
Par exemple :
[root@centos ~]# sleep 1234 ^Z [2]+ Stopped sleep 1234
Once suspended, the bg command can be used to send the process to the background:
[root@centos ~]# bg %2 [2]+ sleep 1234 & [root@centos ~]# jobs -l [1]- 2716 Running sleep 9999 & [2]+ 2742 Running sleep 1234 &
<note important> Note that when the process is sent to the background it resumes normal execution. The - character which follows the [1] indicates that this is that last but one job to have been modified. </note>
To bring the job back to the foreground you cannot suspend it by using the CtrlZ keys. In this case you will have to send a signal to the process. Signals are sent to processes by using the kill kill command:
[root@centos ~]# kill -stop %2 [2]+ Stopped sleep 1234 [root@centos ~]# jobs -l [1]- 2716 Running sleep 9999 & [2]+ 2742 Stopped (signal) sleep 1234
Before bringing the process to the foreground, you can cancel the suspend status:
[root@centos ~]# kill -cont %2 [root@centos ~]# jobs -l [1]- 2716 Running sleep 9999 & [2]+ 2742 Running sleep 1234 &
Now bring the process to the foreground:
[root@centos ~]# kill -stop %2 [root@centos ~]# jobs -l [1]- 2716 Running sleep 9999 & [2]+ 2742 Stopped (signal) sleep 1234 [root@centos ~]# fg %2 sleep 1234 ^C [root@centos ~]#
<note important> Note that we have used the CtrlC keys to kill the process once in the foreground. </note>
The command line switches for the jobs command are :
[root@centos ~]# help jobs jobs: jobs [-lnprs] [jobspec ...] or jobs -x command [args] Display status of jobs. Lists the active jobs. JOBSPEC restricts output to that job. Without options, the status of all active jobs is displayed. Options: -l lists process IDs in addition to the normal information -n list only processes that have changed status since the last notification -p lists process IDs only -r restrict output to running jobs -s restrict output to stopped jobs If -x is supplied, COMMAND is run after all job specifications that appear in ARGS have been replaced with the process ID of that job's process group leader. Exit Status: Returns success unless an invalid option is given or an error occurs. If -x is used, returns the exit status of COMMAND.
Tha wait command makes an asynchronous process react like a synchronous process:
[root@centos ~]# jobs -l [1]+ 2716 Running sleep 9999 & [root@centos ~]# wait %1 ^C [root@centos ~]# jobs -l [1]+ 2716 Running sleep 9999 &
<note important> Note that the CtrlC key combination kills the process associated with the wait command and not the sleep command. </note>
This command is used to change the process priority. The default nice value when a process is started is 10. The highest value of nice is -20, whilst the lowest value is 19. Only root can give a process a value between 0 and -20:
[root@centos ~]# nice -n -20 sleep 1234 ^Z [2]+ Stopped nice -n -20 sleep 1234 [root@centos ~]# ps lx | grep sleep F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND 0 0 2716 2697 20 0 4064 488 - S pts/0 0:00 sleep 9999 4 0 2893 2697 0 -20 4064 488 - T< pts/0 0:00 sleep 1234 0 0 2907 2697 20 0 4356 724 - S+ pts/0 0:00 grep sleep [root@centos ~]# nice -n 19 sleep 5678 ^Z [3]+ Stopped nice -n 19 sleep 5678 [root@centos ~]# ps lx | grep sleep F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND 0 0 2716 2697 20 0 4064 488 - S pts/0 0:00 sleep 9999 4 0 2893 2697 0 -20 4064 488 - T< pts/0 0:00 sleep 1234 0 0 2922 2697 39 19 4064 488 - TN pts/0 0:00 sleep 5678 0 0 2925 2697 20 0 4360 728 - S+ pts/0 0:00 grep sleep
As you can see, the 6th column contains the nice value. This value is applied to the 5th column and alters the process priority. The lower the number, the higher the priority.
The command line switches for the nice command are :
[root@centos ~]# nice --help Usage: nice [OPTION] [COMMAND [ARG]...] Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Nicenesses range from -20 (most favorable scheduling) to 19 (least favorable). -n, --adjustment=N add integer N to the niceness (default 10) --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of nice, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. Report nice bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> For complete documentation, run: info coreutils 'nice invocation'
This command is used to change the process priority of an already running process. Only the process owner and root can renice a process:
[root@centos ~]# jobs -l [1] 2716 Running sleep 9999 & [2]- 2893 Stopped nice -n -20 sleep 1234 [3]+ 2922 Stopped nice -n 19 sleep 5678 [root@centos ~]# bg %2 [2]- nice -n -20 sleep 1234 & [root@centos ~]# bg %3 [3]+ nice -n 19 sleep 5678 & [root@centos ~]# jobs -l [1] 2716 Running sleep 9999 & [2]- 2893 Running nice -n -20 sleep 1234 & [3]+ 2922 Running nice -n 19 sleep 5678 & [root@centos ~]# renice +5 2893 2893: old priority -20, new priority 5 [root@centos ~]# renice -5 2922 2922: old priority 19, new priority -5 [root@centos ~]# ps lx | grep sleep 0 0 2716 2697 20 0 4064 488 - S pts/0 0:00 sleep 9999 4 0 2893 2697 25 5 4064 488 - SN pts/0 0:00 sleep 1234 0 0 2922 2697 15 -5 4064 488 - S< pts/0 0:00 sleep 5678 0 0 2975 2697 20 0 4360 728 - S+ pts/0 0:00 grep sleep
The command line switches for the renice command are :
[root@centos ~]# renice --help Usage: renice [-n] priority [-p|--pid] pid [... pid] renice [-n] priority -g|--pgrp pgrp [... pgrp] renice [-n] priority -u|--user user [... user] renice -h | --help renice -v | --version
This command allows a process to continue after closing the terminal in which is was launched:
nohup lp ventes.txt &
The command line switches for the nohup command are :
[root@centos ~]# nohup --help Usage: nohup COMMAND [ARG]... or: nohup OPTION Run COMMAND, ignoring hangup signals. --help display this help and exit --version output version information and exit If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to `nohup.out' if possible, `$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use `nohup COMMAND > FILE'. NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. Report nohup bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> For complete documentation, run: info coreutils 'nohup invocation'
As we have already seen, the kill command is used to send signals to processes. Possible signals can be:
[root@centos ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX
<note important> Each signal has a number. As a result kill -19 is equivalent to kill -stop. </note>
The most usefull signals are as follows:
Numéro | Description |
---|---|
-2 | Equivalent to the CtrlC key combination |
-9 | A brutal way of killing a process |
-15 | The correct way of killing a process |
~~DISCUSSION:off~~
<html> <center> Copyright © 2011-2014 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”><img alt=“Creative Commons License” style=“border-width:0” src=“https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png” /></a><br />This work is licensed under a <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”>Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a> </center> </html>