Linux – Processes Commands (Faq)
1. top
This command is majorly used to monitor CPU information and Load average.
[sdbt ~]$ toptop – 16:35:37 up 1 day, 7:07, 8 users, load average: 0.38, 0.18, 0.22
Tasks: 404 total, 2 running, 402 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.4%us, 0.2%sy, 0.0%ni, 99.0%id, 0.5%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 7620288k total, 7152756k used, 467532k free, 121288k buffers
Swap: 31457276k total, 36260k used, 31421016k free, 5369308k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
49959 oracle 20 0 1040m 44m 42m R 15.7 0.6 0:03.18 oracle
9590 sdbt 20 0 1033m 195m 38m S 2.0 2.6 3:44.48 firefox
12353 oracle 20 0 2477m 16m 14m S 2.0 0.2 0:15.65 oracle
50362 sdbt 20 0 15348 1360 836 R 2.0 0.0 0:00.01 top
1 root 20 0 19408 1560 1252 S 0.0 0.0 0:01.36 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.03 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.12 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/u:0H
2. To kill a process
[sdbt ~]$ kill -9 508383. To check disk free space.
[sdbt ~]$ df -hFilesystem Size Used Avail Use% Mounted on
/dev/sda10 100G 60G 35G 64% /
tmpfs 3.7G 1.8M 3.7G 1% /dev/shm
/dev/sda2 99G 60M 94G 1% /archive
/dev/sda3 99G 60M 94G 1% /asmdisk1
/dev/sda5 99G 60M 94G 1% /asmdisk2
/dev/sda6 99G 60M 94G 1% /asmdisk3
/dev/sda7 99G 60M 94G 1% /asmdisk4
/dev/sda8 99G 67M 94G 1% /backup
/dev/sda1 197G 42G 146G 22% /oracle
4. du- estimate file space usage
Mostly we will use
$du -skh * – to check the files and folders size in present Directory
$du -a |grep filename – to search a file
5. vmstat Report information about processes, memory, paging, block IO, traps and CPU activity.
Look into swap in and swap out
[sdbt ~]$ vmstatprocs ———–memory———- —swap– —–io—- –system– —–cpu—–
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 1 39372 225180 113832 5716948 0 0 9 36 89 3 0 0 99 0 0
used as $vmstat 1 10 (1 is for every 1 sec and 10 is repetitions)
6. iostat x y -> Monitor IO disk metrics.
[sdbt ~]$ iostat -d 6 2Linux 3.8.13-44.1.1.el6
uek.x86_64 (acs.localdomain) 07/10/2018 _x86_64_ (4 CPU)
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 13.24 169.59 1276.99 4903444 36922672
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 45.83 6.67 11506.67 40 69040
7. sleep – Pause for a specified amount of time(seconds).
[sdbt ~]$ sleep 10 – wait for 10 secs ( we will be using this shells scripts)8. Print the command to check which process is using(reading/writing) a file.
[sdbt ~]$ lsof|grep jlaxmi|headgnome-key 14976 sdbt cwd DIR 8,10 4096 1708002 /var/gdm
gnome-key 14976 sdbt rtd DIR 8,10 4096 2 /
gnome-key 14976 sdbt txt REG 8,10 703656 533885 /usr/bin/gnome-keyring-daemon
gnome-key 14976 sdbt mem REG 8,10 161776 3411402 /lib64/ld-2.12.so
gnome-key 14976 sdbt mem REG 8,10 91096 3411411 /lib64/libz.so.1.2.3
gnome-key 14976 sdbt mem REG 8,10 1930416 3411403 /lib64/libc-2.12.so
gnome-key 14976 sdbt mem REG 8,10 146592 3411405 /lib64/libpthread-2.12.so
gnome-key 14976 sdbt mem REG 8,10 23088 3411406 /lib64/libdl-2.12.so
gnome-key 14976 sdbt mem REG 8,10 47760 3411407 /lib64/librt-2.12.so
gnome-key 14976 sdbt mem REG 8,10 1142944 3411424 /lib64/libglib-2.0.so.0.2800.8
9. Monitor OS log.
[sdbt ~]$ dmesgor
[sdbt ~]$ cat /var/log/messages