| Chapter 1: Foundations of Kali Linux




Download 22,59 Mb.
Pdf ko'rish
bet28/225
Sana14.05.2024
Hajmi22,59 Mb.
#232856
1   ...   24   25   26   27   28   29   30   31   ...   225
Bog'liq
learningkalilinux

22 | Chapter 1: Foundations of Kali Linux


Example 1-4. Using top for process listings
top - 20:14:23 up 3 days, 49 min, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 139 total, 1 running, 138 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.2 sy, 0.0 ni, 99.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 4050260 total, 2722564 free, 597428 used, 730268 buff/cache
KiB Swap: 4192252 total, 4192252 free, 0 used. 3186224 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6995 root 20 0 105384 6928 5932 S 0.3 0.2 0:00.11 sshd
7050 root 20 0 47168 3776 3160 R 0.3 0.1 0:00.09 top
1 root 20 0 154048 8156 6096 S 0.0 0.2 0:02.45 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.06 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:+
5 root 20 0 0 0 0 S 0.0 0.0 0:01.20 kworker/u4+
6 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 mm_percpu_+
7 root 20 0 0 0 0 S 0.0 0.0 0:00.20 ksoftirqd/0
8 root 20 0 0 0 0 S 0.0 0.0 0:38.25 rcu_sched
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
In addition to providing a list of processes, the amount of memory they are using, the
percentage of CPU being used, as well as other specifics, 
top
shows details about the
running system, which you will see at the top. Each time the display refreshes, the
process list will rearrange, indicating which processes are consuming the most
resources at the top. As you will note, 
top
itself consumes some amount of resources,
and you will often see it near the top of the process list. One of the important fields
that you will see not only in 
top
but also in 
ps
is the PID. In addition to providing a
way of clearly identifying one process from another, particularly when the name of
the process is the same, it also provides a way of sending messages to the process.
You will find two commands invaluable when you are managing processes. They are
closely related, performing the same function, though offering slightly different capa‐
bilities. The first command is 
kill
, which, perhaps unsurprisingly, can kill a running
process. More specifically, it sends a signal to the process. The operating system will
interact with processes by sending signals to them. Signals are one means of interpro‐
cess communication (IPC). The default signal for 
kill
is the TERM signal (SIG‐
TERM), which means 
terminate
, but if you specify a different signal, 
kill
will send that
signal instead. To send a different signal, you issue 
kill -# pid
, where # indicates the
number that equates to the signal you intend to send, and 
pid
is the process identifi‐
cation number that you can find from using either 
ps
or 
top
.
Signals
The signals for a system are provided in a C header file. The easiest way to get a list‐
ing of all the signals with their numeric value as well as the mnemonic identifier for
the signal is to run 
kill -l
, as you can see here:

Download 22,59 Mb.
1   ...   24   25   26   27   28   29   30   31   ...   225




Download 22,59 Mb.
Pdf ko'rish