Understanding Resources From OS perspective

     All activities in a computer can be tracked by Linux Commands




Command Usage
ps -eaf | grep ProcessName    find the pid , ppid  of the process
ps -eaf | grep ProcessName    find the binary path of the process
ps -eaf | grep ProcessName Find the user under which the process is running
pidof ProcessName pid of the running process
lsof -p “pidof the the process” gives all the resources held by the process(files, ports, binaries, streams)
fuser FileName gives the pid of the process holding the file


Process Interaction with other resources

Process interaction with CPU And RAM   top -p pidOfTheProcess
To list all the resources lsof -p pidofProcess.
To list all network ports acquired by process netstat -pant | grep 2043
To find disk io done by process  iotop -p 2043



Storage :

Commands    Usage
lsblk In detail info of all Hardisk attched
sudo fdisk -l Info of Proc FileSystem And Disk FileSystem
df -hk Dir Usage
/etc/fstab File which holds info about the hardisk attached
iostat -d -x 5 Live I/O info of the hardisk
lsblk -o NAME,PHY-SeC Physical Sector of each hardisk
hdparm -I /dev/sdX  All info about the Hardisk (Manufacturer, configuration)





Commands Usage
ifconfig All possible ways of network interfaces available
lsof -i All host:port connectivity
netstat -i I/O happening on network card
Iftop Network Top to get live IO metrics
iptraf Grpahical Interface to monitor Network IO
ifstat -t -i eth0 0.5



Commands Usage
sar -u 2 All cpu Combined metrics
iostat -c -x 3 All cpu Combined metrics
mpstat -P ALL Individual Cores usage
top CPU + RAM usage


Swap Space

Commands Usage
sudo ps -eo min_flt,maj_flt,cmd
/usr/bin/time -v ls /etc/passwd Figures out swap used during comand execution
grep pgfault /proc/vmstat Page Faults that has happened till now
cut -d ” ” -f 1,2,10,12 /proc/pid/stat /proc/pid/stat  Swap info about a running process



OS page cache and Disk cache


Flushing out Page(OS) Cache

$ sudo sh -c ‘echo 3 >/proc/sys/vm/drop_caches’


Flush Disk Cache :

blockdev –flushbufs /dev/sda

hdparm -F /dev/sda