Note: This is an RHCSA 7 exam objective.
System Activities
To get an instantaneous image of a server activity (use ‘virt-top‘ on a KVM hypervisor), type:
# top
To get details about processes, type:
# ps -edf
Process Priority
To start a process (here script.sh) with a low priority, type:
# nice -n 10 ./script.sh
To change the priority (here +5) of an already running process, get its PID (Process ID) through top or ps (here 789) and type:
# renice +5 789
Alternatively:
# renice +5 `pgrep script.sh`
Process Deletion
To kill the process, get its PID through top or ps (here 789) and type:
# kill -9 789
Alternatively:
# pkill script.sh
System Reporting
To display details about IO activities, type:
# iostat
To show network card activities, type:
# netstat -i
To display socket activities, type:
# netstat -a
To get details about virtual memory activities (memory, swap, run queue, cpu usage, etc) every 5 second, type:
# vmstat 5
To get a full report of a server activity, type:
# sar -A
Additional Resources
You can also watch a video by Sander van Vugt about Understanding Linux Memory Usage (4min/2016).
Just a comment about `kill -9` This is not the default behavior and rarely used on for well written programs. `kill` sends SIGTERM as default to a process so the process needs time for a clean up of open files, FD’s etc.
Yes and if the program doesn’t handle the SIGTERM signal, nothing happens.
I’m perfectly aware of that.
I guess PackageKit isn’t a well written program, since I have to put up a fight with it first via several kill -9 on it before being able to use yum install to install stuff on my virtual CentOS installation.
Long time Solaris / Linux newbie. A note on sar that is probably apparent to most but I had to do a look up on it: it is a part of the sysstat tool set that did not get installed on my minimum distro.
yum install sysstat
Great site, using it for RHCSA at the moment and feeling pretty well prepared after a week of intense studying!
Thank you.