Bash
プロセスやシステム情報の表示
プロセス情報の表示 (ps)
現在の端末 (TTY) で実行中の自分のプロセスを表示するには,「ps
」コマンドを利用します.具体的には自分がいま開いているシェルで動いているプロセスだけを確認したいときに次のコマンドを利用します.
rinsaka@ubuntu:~/Documents/work$ ps ⏎
PID TTY TIME CMD
2639 pts/0 00:00:00 bash
2958 pts/0 00:00:00 ps
rinsaka@ubuntu:~/Documents/work$
他のユーザのプロセスを含むすべての端末 (TTY) 上のプロセスを表示するには「a
」オプションを追加します.具体的には,複数のユーザがログインしているシステムで,端末に紐づいたプロセスを広く確認したいときに次のようなコマンドを実行します.
rinsaka@ubuntu:~/Documents/work$ ps a ⏎
PID TTY STAT TIME COMMAND
1535 tty6 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear - linux
1614 tty1 Ss 0:00 /bin/login -p --
2113 tty1 S+ 0:00 -bash
2639 pts/0 Ss 0:00 -bash
2959 pts/0 R+ 0:00 ps a
rinsaka@ubuntu:~/Documents/work$
出力をユーザ形式 (user-orientied format) で表示するには「u
」オプションを指定します.これにより,ユーザ名 (USER),CPU使用率 (%CPU),メモリ使用率 (%MEM),開始時刻 (START) などの情報が表示されるようになります.
rinsaka@ubuntu:~/Documents/work$ ps u ⏎
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
rinsaka 2113 0.0 0.1 8656 5632 tty1 S+ 01:02 0:00 -bash
rinsaka 2639 0.0 0.1 8784 5504 pts/0 Ss 01:34 0:00 -bash
rinsaka 2960 0.0 0.1 10884 4480 pts/0 R+ 02:18 0:00 ps u
rinsaka@ubuntu:~/Documents/work$
端末に紐付いていないプロセスも含めて,自分のすべてのプロセスを表示するには「x」オプションを指定します.この場合,バックグラウンドで動いている GUI アプリやデーモンなど,TTY を持たないプロセスも確認できます.
rinsaka@ubuntu:~/Documents/work$ ps x ⏎
PID TTY STAT TIME COMMAND
2101 ? Ss 0:00 /usr/lib/systemd/systemd --user
2102 ? S 0:00 (sd-pam)
2113 tty1 S+ 0:00 -bash
2638 ? S 0:11 sshd: rinsaka@pts/0
2639 pts/0 Ss 0:00 -bash
2961 pts/0 R+ 0:00 ps x
rinsaka@ubuntu:~/Documents/work$
上で説明したオプションは組み合わせて利用できます.例えば「au
」とすると,すべての端末上のプロセス (a
) を,ユーザ形式 (u
) で表示できます.
rinsaka@ubuntu:~/Documents/work$ ps au ⏎
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1535 0.0 0.0 6104 1920 tty6 Ss+ 01:01 0:00 /sbin/agetty
root 1614 0.0 0.1 6944 4608 tty1 Ss 01:02 0:00 /bin/login -p
rinsaka 2113 0.0 0.1 8656 5632 tty1 S+ 01:02 0:00 -bash
rinsaka 2639 0.0 0.1 8784 5504 pts/0 Ss 01:34 0:00 -bash
rinsaka 2965 0.0 0.1 10884 4480 pts/0 R+ 02:19 0:00 ps au
rinsaka@ubuntu:~/Documents/work$
「aux
」オプションを指定するとすべてのユーザのすべてのプロセスを,ユーザ形式で表示できます.これはシステム全体のプロセスを詳細に確認したいとき,システム管理者がよく利用する形式です.
rinsaka@ubuntu:~/Documents/work$ ps aux ⏎
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.3 22228 13376 ? Ss 00:59 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S 00:59 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 00:59 0:00 [pool_workque
root 4 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-rc
root 5 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-rc
root 6 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sl
root 7 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ne
root 8 0.0 0.0 0 0 ? I 00:59 0:04 [kworker/0:0-
root 9 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/0:0H
root 11 0.0 0.0 0 0 ? I 00:59 0:00 [kworker/u256
root 12 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-mm
root 13 0.0 0.0 0 0 ? I 00:59 0:00 [rcu_tasks_kt
root 14 0.0 0.0 0 0 ? I 00:59 0:00 [rcu_tasks_ru
root 15 0.0 0.0 0 0 ? I 00:59 0:00 [rcu_tasks_tr
root 16 0.0 0.0 0 0 ? S 00:59 0:00 [ksoftirqd/0]
root 17 0.0 0.0 0 0 ? I 00:59 0:00 [rcu_preempt]
root 18 0.0 0.0 0 0 ? S 00:59 0:00 [migration/0]
root 19 0.0 0.0 0 0 ? S 00:59 0:00 [idle_inject/
root 20 0.0 0.0 0 0 ? S 00:59 0:00 [cpuhp/0]
root 21 0.0 0.0 0 0 ? S 00:59 0:00 [cpuhp/1]
root 22 0.0 0.0 0 0 ? S 00:59 0:00 [idle_inject/
root 23 0.0 0.0 0 0 ? S 00:59 0:00 [migration/1]
root 24 0.0 0.0 0 0 ? S 00:59 0:00 [ksoftirqd/1]
root 29 0.0 0.0 0 0 ? S 00:59 0:00 [kdevtmpfs]
root 30 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-in
root 32 0.0 0.0 0 0 ? S 00:59 0:00 [kauditd]
root 34 0.0 0.0 0 0 ? S 00:59 0:00 [khungtaskd]
root 35 0.0 0.0 0 0 ? S 00:59 0:00 [oom_reaper]
root 37 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-wr
root 38 0.0 0.0 0 0 ? S 00:59 0:00 [kcompactd0]
root 39 0.0 0.0 0 0 ? SN 00:59 0:00 [ksmd]
root 41 0.0 0.0 0 0 ? I 00:59 0:00 [kworker/1:2-
root 42 0.0 0.0 0 0 ? SN 00:59 0:00 [khugepaged]
root 43 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ki
root 44 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-kb
root 45 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-bl
root 46 0.0 0.0 0 0 ? S 00:59 0:00 [irq/9-acpi]
root 47 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-tp
root 48 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-at
root 49 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-md
root 50 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-md
root 51 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ed
root 52 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-de
root 53 0.0 0.0 0 0 ? S 00:59 0:00 [watchdogd]
root 54 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/1:1H
root 55 0.0 0.0 0 0 ? S 00:59 0:00 [kswapd0]
root 56 0.0 0.0 0 0 ? S 00:59 0:00 [ecryptfs-kth
root 57 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-kt
root 58 0.0 0.0 0 0 ? S 00:59 0:00 [irq/24-pcieh
root 59 0.0 0.0 0 0 ? S 00:59 0:00 [irq/25-pcieh
root 60 0.0 0.0 0 0 ? S 00:59 0:00 [irq/26-pcieh
root 61 0.0 0.0 0 0 ? S 00:59 0:00 [irq/27-pcieh
root 62 0.0 0.0 0 0 ? S 00:59 0:00 [irq/28-pcieh
root 63 0.0 0.0 0 0 ? S 00:59 0:00 [irq/29-pcieh
root 64 0.0 0.0 0 0 ? S 00:59 0:00 [irq/30-pcieh
root 65 0.0 0.0 0 0 ? S 00:59 0:00 [irq/31-pcieh
root 66 0.0 0.0 0 0 ? S 00:59 0:00 [irq/32-pcieh
root 67 0.0 0.0 0 0 ? S 00:59 0:00 [irq/33-pcieh
root 68 0.0 0.0 0 0 ? S 00:59 0:00 [irq/34-pcieh
root 69 0.0 0.0 0 0 ? S 00:59 0:00 [irq/35-pcieh
root 70 0.0 0.0 0 0 ? S 00:59 0:00 [irq/36-pcieh
root 71 0.0 0.0 0 0 ? S 00:59 0:00 [irq/37-pcieh
root 72 0.0 0.0 0 0 ? S 00:59 0:00 [irq/38-pcieh
root 73 0.0 0.0 0 0 ? S 00:59 0:00 [irq/39-pcieh
root 74 0.0 0.0 0 0 ? S 00:59 0:00 [irq/40-pcieh
root 75 0.0 0.0 0 0 ? S 00:59 0:00 [irq/41-pcieh
root 76 0.0 0.0 0 0 ? S 00:59 0:00 [irq/42-pcieh
root 77 0.0 0.0 0 0 ? S 00:59 0:00 [irq/43-pcieh
root 78 0.0 0.0 0 0 ? S 00:59 0:00 [irq/44-pcieh
root 79 0.0 0.0 0 0 ? S 00:59 0:00 [irq/45-pcieh
root 80 0.0 0.0 0 0 ? S 00:59 0:00 [irq/46-pcieh
root 81 0.0 0.0 0 0 ? S 00:59 0:00 [irq/47-pcieh
root 82 0.0 0.0 0 0 ? S 00:59 0:00 [irq/48-pcieh
root 83 0.0 0.0 0 0 ? S 00:59 0:00 [irq/49-pcieh
root 84 0.0 0.0 0 0 ? S 00:59 0:00 [irq/50-pcieh
root 85 0.0 0.0 0 0 ? S 00:59 0:00 [irq/51-pcieh
root 86 0.0 0.0 0 0 ? S 00:59 0:00 [irq/52-pcieh
root 87 0.0 0.0 0 0 ? S 00:59 0:00 [irq/53-pcieh
root 88 0.0 0.0 0 0 ? S 00:59 0:00 [irq/54-pcieh
root 89 0.0 0.0 0 0 ? S 00:59 0:00 [irq/55-pcieh
root 90 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ac
root 91 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_0]
root 92 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 93 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_1]
root 94 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 98 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ml
root 99 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/0:1H
root 100 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ip
root 107 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ks
root 109 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/u259
root 110 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/u260
root 111 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/u261
root 116 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-cr
root 118 0.0 0.0 0 0 ? I 00:59 0:02 [kworker/1:4-
root 128 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ch
root 178 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-mp
root 179 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_2]
root 180 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 181 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-mp
root 182 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_3]
root 183 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 184 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_4]
root 185 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 186 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_5]
root 187 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 188 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_6]
root 189 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 190 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_7]
root 193 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 194 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_8]
root 195 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 196 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_9]
root 201 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 203 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_10]
root 205 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 206 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_11]
root 207 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 214 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_12]
root 215 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 217 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_13]
root 218 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 219 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_14]
root 220 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 222 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_15]
root 223 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 224 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_16]
root 225 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 226 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_17]
root 227 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 228 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_18]
root 229 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 230 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_19]
root 231 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 232 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_20]
root 233 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 234 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_21]
root 235 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 236 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_22]
root 237 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 238 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_23]
root 239 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 240 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_24]
root 241 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 242 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_25]
root 243 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 244 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_26]
root 245 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 246 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_27]
root 247 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 248 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_28]
root 249 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 250 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_29]
root 251 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 252 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_30]
root 253 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 254 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_31]
root 255 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 285 0.0 0.0 0 0 ? S 00:59 0:00 [scsi_eh_32]
root 286 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-sc
root 293 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/1:2H
root 306 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-kd
root 339 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ra
root 378 0.0 0.0 0 0 ? S 00:59 0:00 [jbd2/dm-0-8]
root 379 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ex
root 451 0.0 0.3 50496 15548 ? S<s 00:59 0:00 /usr/lib/syst
root 475 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-km
root 476 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-km
root 484 0.0 0.0 0 0 ? I 00:59 0:00 [kworker/u256
root 487 0.0 0.6 354628 27264 ? SLsl 00:59 0:00 /sbin/multipa
root 527 0.0 0.2 30824 9472 ? Ss 00:59 0:00 /usr/lib/syst
root 528 0.0 0.0 0 0 ? S 00:59 0:00 [psimon]
root 613 0.0 0.0 0 0 ? S 00:59 0:00 [jbd2/sda2-8]
root 614 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-ex
systemd+ 661 0.0 0.3 21584 12800 ? Ss 00:59 0:00 /usr/lib/syst
systemd+ 666 0.0 0.2 91020 7936 ? Ssl 00:59 0:00 /usr/lib/syst
root 745 0.0 0.0 0 0 ? S 00:59 0:00 [irq/57-vmw_v
root 747 0.0 0.0 0 0 ? S 00:59 0:00 [irq/58-vmw_v
root 748 0.0 0.0 0 0 ? S 00:59 0:00 [irq/59-vmw_v
root 754 0.0 0.0 0 0 ? S 00:59 0:00 [irq/16-vmwgf
root 755 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-tt
root 767 0.0 0.2 50792 11648 ? Ss 00:59 0:00 /usr/bin/VGAu
root 768 0.1 0.2 239532 9088 ? Ssl 00:59 0:08 /usr/bin/vmto
root 981 0.0 0.0 0 0 ? I< 00:59 0:00 [kworker/R-cf
root 1091 0.0 0.0 4236 2432 ? Ss 00:59 0:00 /usr/sbin/cro
message+ 1092 0.0 0.1 9792 5376 ? Ss 00:59 0:00 @dbus-daemon
polkitd 1097 0.0 0.2 308164 7936 ? Ssl 00:59 0:00 /usr/lib/polk
root 1104 0.0 0.2 18124 8704 ? Ss 00:59 0:00 /usr/lib/syst
root 1113 0.0 0.3 468988 13312 ? Ssl 00:59 0:00 /usr/libexec/
root 1138 0.0 0.5 107024 22912 ? Ssl 00:59 0:00 /usr/bin/pyth
syslog 1170 0.0 0.1 222508 6180 ? Ssl 00:59 0:00 /usr/sbin/rsy
root 1191 0.0 0.3 392028 12800 ? Ssl 00:59 0:00 /usr/sbin/Mod
root 1523 0.0 0.0 0 0 ? I< 01:00 0:00 [kworker/R-tl
root 1535 0.0 0.0 6104 1920 tty6 Ss+ 01:01 0:00 /sbin/agetty
root 1614 0.0 0.1 6944 4608 tty1 Ss 01:02 0:00 /bin/login -p
systemd+ 1824 0.0 0.2 18980 9472 ? Ss 01:02 0:00 /usr/lib/syst
root 2099 0.0 0.0 0 0 ? S 01:02 0:00 [psimon]
rinsaka 2101 0.0 0.2 20264 11392 ? Ss 01:02 0:00 /usr/lib/syst
rinsaka 2102 0.0 0.0 21144 3516 ? S 01:02 0:00 (sd-pam)
rinsaka 2113 0.0 0.1 8656 5632 tty1 S+ 01:02 0:00 -bash
root 2125 0.0 0.2 12020 8064 ? Ss 01:03 0:00 sshd: /usr/sb
root 2503 0.0 0.0 0 0 ? I 01:21 0:00 [kworker/u257
root 2582 0.0 0.0 0 0 ? I 01:34 0:00 [kworker/0:3]
root 2583 0.0 0.2 14960 10496 ? Ss 01:34 0:00 sshd: rinsaka
rinsaka 2638 0.4 0.1 15120 6848 ? S 01:34 0:12 sshd: rinsaka
rinsaka 2639 0.0 0.1 8784 5504 pts/0 Ss 01:34 0:00 -bash
root 2654 0.0 0.0 0 0 ? I 01:35 0:00 [kworker/u258
root 2837 0.0 0.0 0 0 ? I 01:55 0:00 [kworker/u258
root 2838 0.0 0.0 0 0 ? I 01:55 0:00 [kworker/u257
root 2877 0.0 0.0 0 0 ? I 02:01 0:00 [kworker/u258
root 2878 0.0 0.0 0 0 ? I 02:01 0:00 [kworker/u257
root 2931 0.0 0.0 0 0 ? I 02:11 0:00 [kworker/u258
root 2942 0.0 0.0 0 0 ? I 02:15 0:00 [kworker/u257
rinsaka 2968 0.0 0.1 10884 4480 pts/0 R+ 02:20 0:00 ps aux
rinsaka@ubuntu:~/Documents/work$
プロセスの終了 (kill)
次はプロセスの終了方法について確認します.ある端末(ターミナル)で,例えば次のコマンドを実行し,終了する前にそのままの状態で待機します.
rinsaka@ubuntu:~/Documents/work$ cat -n test1.txt | less ⏎
もう一つの端末(ターミナル)を起動し,そのターミナルで実行中のプロセスを確認します.すると,上で実行中のコマンド「less
」があり,その「PID」が3242であることが確認できました.
rinsaka@ubuntu:~$ ps au ⏎ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1535 0.0 0.0 6104 1920 tty6 Ss+ 01:01 0:00 /sbin/agetty root 1614 0.0 0.1 6944 4608 tty1 Ss 01:02 0:00 /bin/login -p rinsaka 2113 0.0 0.1 8656 5632 tty1 S+ 01:02 0:00 -bash rinsaka 3139 0.0 0.1 8652 5504 pts/0 Ss 03:28 0:00 -bash rinsaka 3197 0.0 0.1 8784 5760 pts/1 Ss 03:29 0:00 -bash rinsaka 3242 0.0 0.0 6072 2560 pts/1 S+ 03:30 0:00 less rinsaka 3243 0.0 0.1 10884 4480 pts/0 R+ 03:30 0:00 ps au rinsaka@ubuntu:~$
実行中のプロセスを終了するには「kill
」コマンドを使用します.どのプロセスを終了させるかは上の「ps
」コマンドで取得した PID を指定します.
rinsaka@ubuntu:~$ kill 3242 ⏎
rinsaka@ubuntu:~$
上のコマンドを実行すると,「cat -n test1.txt | less
」 コマンドを実行していた端末(ターミナル)で実行が終了し,プロンプトが再び表示されるはずです.実際に終了しているかどうかはもう再び次のコマンドを実行することでも確認できます.
rinsaka@ubuntu:~$ ps au ⏎
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1535 0.0 0.0 6104 1920 tty6 Ss+ 01:01 0:00 /sbin/agetty
root 1614 0.0 0.1 6944 4608 tty1 Ss 01:02 0:00 /bin/login -p
rinsaka 2113 0.0 0.1 8656 5632 tty1 S+ 01:02 0:00 -bash
rinsaka 3139 0.0 0.1 8652 5504 pts/0 Ss 03:28 0:00 -bash
rinsaka 3197 0.0 0.1 8784 5760 pts/1 Ss+ 03:29 0:00 -bash
rinsaka 3244 0.0 0.1 10884 4480 pts/0 R+ 03:30 0:00 ps au
rinsaka@ubuntu:~$
プロセスの表示 (top)
現在実行中のプロセスを CPU 利用率が高い順にリアルタイムで確認するには「top
」コマンドを利用します.表示はリアルタイムに更新されます.終了するには q を押します.
rinsaka@ubuntu:~$ top ⏎
top - 04:03:39 up 3:04, 3 users, load average: 0.00, 0.00, 0.00
Tasks: 216 total, 1 running, 215 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3868.2 total, 3199.2 free, 518.7 used, 399.6 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 3349.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
768 root 20 0 313264 9344 7808 S 0.3 0.2 0:17.51 vmtoolsd
3475 rinsaka 20 0 11904 5888 3712 R 0.3 0.1 0:00.03 top
1 root 20 0 22228 13376 9408 S 0.0 0.3 0:02.77 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pool_wo+
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
5 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
7 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
8 root 20 0 0 0 0 I 0.0 0.0 0:07.80 kworker+
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
11 root 20 0 0 0 0 I 0.0 0.0 0:00.00 kworker+
12 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker+
13 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_tas+
14 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_tas+
15 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_tas+
16 root 20 0 0 0 0 S 0.0 0.0 0:00.04 ksoftir+
17 root 20 0 0 0 0 I 0.0 0.0 0:00.33 rcu_pre+
ファイルシステム使用量の表示 (df)
ファイルシステムの使用量や空き容量を確認するには 「df
」コマンドを実行します.このときブロック単位で表示されるので直感的ではないかもしれません.
rinsaka@ubuntu:~/Documents/work$ df ⏎
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 396100 1568 394532 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 10218772 2554988 7123112 27% /
tmpfs 1980492 0 1980492 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
/dev/sda2 1790136 101908 1578968 7% /boot
tmpfs 396096 12 396084 1% /run/user/1000
rinsaka@ubuntu:~/Documents/work$
「-h
」オプションを付与するとわかりやすい単位で表示してくれます.
rinsaka@ubuntu:~/Documents/work$ df -h ⏎
Filesystem Size Used Avail Use% Mounted on
tmpfs 387M 1.6M 386M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 9.8G 2.5G 6.8G 27% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 1.8G 100M 1.6G 7% /boot
tmpfs 387M 12K 387M 1% /run/user/1000
rinsaka@ubuntu:~/Documents/work$
メモリ使用量・空き容量の確認 (free)
物理メモリやスワップの使用量,空き容量を確認するには「free
」コマンドが使えます.ただし,これは macOS では利用できません.
rinsaka@ubuntu:~/Documents/work$ free ⏎
total used free shared buff/cache available
Mem: 3960988 521124 3288216 1580 406816 3439864
Swap: 0 0 0
rinsaka@ubuntu:~/Documents/work$
「df
」コマンドと同様に,「-h
」オプションが利用可能です.
rinsaka@ubuntu:~/Documents/work$ free -h ⏎
total used free shared buff/cache available
Mem: 3.8Gi 509Mi 3.1Gi 1.5Mi 397Mi 3.3Gi
Swap: 0B 0B 0B
rinsaka@ubuntu:~/Documents/work$