Giriş
process'ler hakkında bilgi verir. Açıklaması
şöyle.
This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, which may be grouped and must not be used with a dash.
3 GNU long options, which are preceded by two dashes.
Parametreler
Açıklaması
şöyle. Ben parametrelere hep çizgi (-) ile başlıyorum
If we pass arguments with a (-) dash then we will get the output in standard syntax. In contrast, if we pass arguments without any (-) dash then we will get output in BSD (Berkeley Software Distribution) syntax.
En Çok Kullandıklarım
1. $ ps -efL
-e ile sahibi kim olursa olsun tüm processleri göster.
-f ile full formatlama yap. Yani tüm sütunları göster
-L ile tüm thread'leri göster
2. ps auxBSD formatında çıktı verir. Şöyle
yaparız$ ps aux | more
--------------------------------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.6 0.5 169396 11312 ? Ss 03:44 0:24 /sbin/init
root 2 0.0 0.0 0 0 ? S 03:44 0:00 [kthreadd]
...
Açıklaması şöyle
%CPU CPU time used by this process (in percentage)
%MEM Physical memory used by this process (in percentage)
VSZ displays the amount of virtual memory being consumed by the process.
RSS is the actual physical wired-in memory that is being used.
START shows the date or time when the process was started.
TIME shows the total CPU time used by this process.
STAT displays the state of a process.
Process state tablosu şöyledirD → Blocked
I → Blocked
R → Waiting or Running
S → Blocked
T → Blocked (more or less)
t → Blocked (more or less)
W → Blocked (obsolete since Linux 1.1.30)
X → Terminated
Z → Terminated
Simple Process Selection
Hangi process'lerin çıktıya dahil edileceğini belirtiriz. Genellikle "all processes" anlamına gelir
-a seçeneği
Açıklaması
şöyle.
a = show processes for all users
Aslında -a seçeneği tüm process'leri göstermiyor. Açıklaması
şöyle. Her şeyi görmek istiyorsak -e daha uygun
Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.
Örnek
Şöyle
yaparız.
ps -aux
-e seçeneği
Açıklaması
şöyle.
e tells ps to display all processes regardless of who owns them or their current status – active, sleeping, paused, waiting for I/O, etc.
Açıklaması
şöyle.
-e Select all processes. Identical to -A.
Örnek
Şöyle
yaparız.
To see every process on the system using standard syntax:
ps -e
ps -ef
ps -eF
ps -ely
To see every process on the system using BSD syntax:
ps ax
ps axu
To print a process tree:
ps -ejH
ps axjf
-x seçeneği
Açıklaması
şöyle. Arka planda çalışan uygulamaları da gösterir.
x = also show processes not attached to a terminal
Process Selection By List
Hangi process'lerin çıktıya dahil edileceğini belirtiriz.
- G seçeneği
Belirtilen gruba ait processleri gösterir Şöyle
yaparız-p seçeneğiProcess ID'sine göre seçmek için kullanılır. Şöyle
yaparız.
ps --ppid 2 -p 2 -o uname,pid,ppid,cmd,cls
-u seçeneği
Belirtilen kullanıcıya ait processleri gösterir Şöyle
yaparız$ ps -u root # by username
Output Format Control
Eğer çıktı için hiç bir format belirtmezse çıktı
şöyle $ ps
--------------------------------------------------------------------
PID TTY TIME CMD
54316 pts/0 00:00:00 bash
54341 pts/0 00:00:00 ps
Bu sütunların açıklaması
şöyle
PID — Unique process ID
TTY — Type of terminal that the user is currently logged in.
TIME — CPU time this process has consumed since it first started running.
CMD — The command used to start the corresponding process.
-f seçeneği
Açıklaması
şöyle.
-f Do full-format listing. This option can be combined with many
other UNIX-style options to add additional columns. It also
causes the command arguments to be printed. When used with
-L, the NLWP (number of threads) and LWP (thread ID) columns
will be added. See the c option, the format keyword args, and
the format keyword comm.
Örnek
Şöyle
yaparız. PGIS ile Process Group ID gösterilir.
$ ps -efj
UID PID PPID PGID SID C STIME TTY TIME CMD
root 1 0 1 1 0 11:18 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root 2 0 0 0 0 11:18 ? 00:00:00 [kthreadd]
root 3 2 0 0 0 11:18 ? 00:00:00 [rcu_gp]
root 4 2 0 0 0 11:18 ? 00:00:00 [rcu_par_gp]
root 6 2 0 0 0 11:18 ? 00:00:00 [kworker/0:0H]
root 8 2 0 0 0 11:18 ? 00:00:00 [mm_percpu_wq]
root 9 2 0 0 0 11:18 ? 00:00:00 [ksoftirqd/0]
root 10 2 0 0 0 11:18 ? 00:00:00 [rcu_sched]
-j seçeneği
Açıklaması şöyle
List process in jobs format.
-o seçeneği
Sadece kullanıcı ismi istersek user şöyle
yaparız.
$ ps axho user --sort -rss | head -1
Örnek
Kullancı bilgisini 16 karakter yapmak istersek şöyle
yaparız
ps ax o user:16,pid,pcpu,pmem,vsz,rss,stat,start_time,time,cmd
-u seçeneği
Açıklaması
şöyle. Uygulamanın sahibini ayrı bir sütunda gösterir.
u = display the process's user/owner
$ ps aux | head -10
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 51120 2796 ? Ss Dec22 0:09 /usr/lib/systemd/...
root 2 0.0 0.0 0 0 ? S Dec22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Dec22 0:04 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< Dec22 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S Dec22 0:15 [migration/0]
root 8 0.0 0.0 0 0 ? S Dec22 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S Dec22 2:47 [rcu_sched]
...
saml 3015 0.0 0.0 117756 596 pts/2 Ss Dec22 0:00 bash
saml 3093 0.9 4.1 1539436 330796 ? Sl Dec22 70:16 /usr/lib64/..
saml 3873 0.0 0.1 1482432 8628 ? Sl Dec22 0:02 gvim -f
root 5675 0.0 0.0 124096 412 ? Ss Dec22 0:02 /usr/sbin/crond -n
root 5777 0.0 0.0 51132 1068 ? Ss Dec22 0:08 /usr/sbin/...
saml 5987 0.7 1.5 1237740 119876 ? Sl Dec26 14:05 /opt/google/chrome/...
root 6115 0.0 0.0 0 0 ? S Dec27 0:06 [kworker/0:2]
Output Modifiers
-h seçeneği
No header in output anlamına
gelir.
-H seçeneği
Ağaç şeklinde gösterir. Şöyle
yaparız. Burada sshd altında çalışan başka sshd process'leri görülebilir.
$ ps -ejH | grep sshd
--------------------------------------------------------------------
614 614 614 ? 00:00:00 sshd
22310 22310 22310 ? 00:00:00 sshd
30267 30267 30267 ? 00:00:00 sshd
33871 33871 33871 ? 00:00:00 sshd
--sort seçeneği
rss'e göre sıralayabiliriz. Şöyle
yaparız.
$ ps axho user --sort -rss | head -1
Şöyle yaparız.
ps axho user,pid,rss --sort -rss | head -1
Thread Display
-L seçeneği
Örnek
Açıklaması
şöyle.
L tells ps to show individual threads
the f tells ps to format the output as a full-format listing, and in conjunction with the L argument the NLWP (number of threads) and LWP (thread ID) columns are added to the output.
Şöyle
yaparız.
ps -eLf