Finding the Greediest Processes with top




Download 7,3 Mb.
Pdf ko'rish
bet79/125
Sana14.05.2024
Hajmi7,3 Mb.
#232858
1   ...   75   76   77   78   79   80   81   82   ...   125
Bog'liq
linuxbasicsforhackers

Finding the Greediest Processes with top
When you enter the 
ps
command, the processes are displayed in the order 
they were started, and since the kernel assigns PIDs in the order they have 
started, what you see are processes ordered by PID number.
In many cases, we want to know which processes are using the most 
resources. This is where the 
top
command comes in handy because it dis­
plays the processes ordered by resources used, starting with the largest. 
Unlike the 
ps
command, which gives us a one­time snapshot of the pro­
cesses, 
top
refreshes the list dynamically—by default, every 3 seconds. 
You can watch and monitor those resource­hungry processes, as shown in 
Listing 6­3.
kali >
top
top - 15:31:17 up 2 days, 6:50, 4 users, load average: 0.00, 0.04, 0.09
Tasks: 176 total, 1 running, 175 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.3 us, 0.7 sy, 0.0 ni, 97.4 id, 0.0 wa, 0.0 hi 0.0 si 0.0
MiB Mem : 1491220 total, 64848 free, 488272 used, 938100 buff/cache
MiB Swap : 1046524 total, 1044356 free, 2168 used. 784476 avail MEM
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
39759 root 20 0 893180 247232 11488 S 0.7 16.6 1:47.88 ruby
39859 root 20 0 27308 16796 14272 S 0.3 1.2 1:47.88 postgres
39933 root 20 0 293936 61500 29108 S 0.7 4.1 1:47.88 Xorg
--
snip
--
Listing 6-3: Finding the greediest processes with 
top
System administrators often keep 
top
running in a terminal to monitor 
use of process resources. As a hacker, you may want to do the same, espe­
cially if you have multiple tasks running on your system. While you have 
top
running, pressing the H or ? key will bring up a list of interactive com­
mands, and pressing Q will quit 
top
. You’ll use 
top
again soon to manage 
your processes in “Changing Process Priority with nice” on page 65 and 
“Killing Processes” on page 66.

Download 7,3 Mb.
1   ...   75   76   77   78   79   80   81   82   ...   125




Download 7,3 Mb.
Pdf ko'rish