Managing Processes
Nov 9, 2025
Using signals to manage process state
man 7 signal
- The
killcommand is used to send signals to PIDs- Alternatively, you can use
kfromtop
- Alternatively, you can use
- Different kill-like commands exist, like
pkillandkillall
Priority management
Note: for RHCSA, only nice and renice is needed
- If processes are equal from a perspective of Cgroups, the Linux
niceandrenicecommands can be used to manage priority nicevalues range from -20 to 19, with -20 being the highest priority, and 19 the lowest- Users can only decrease the priority of their processes
nice -n 19 dd if/dev/zero of=/dev/null- Priority is always relative to other processes
Kernel Tuning
/proc/sys and sysctl
- Kernel tunables are provided through the
/proc/sysdirectory in the/procpseudo file system - Change the current value by echoing a new value into the file
cat /proc/sys/vm/swappinessecho 40 > /proc/sys/vm/swappiness
- To make settings persistent, write them to a file in
/etc/systctl.d
cat >> swappiness.conf << EOF
vm.swappiness = 40
EOF
tuned
tuned-adm listshows current profilestuned-adm profile {profile}sets another profile- Each profile contains a file with the name tuned.conf that has a wide range of performance related settings
- The
reapply_sysctl=1parameter in/etc/tuned/tuned-main.confensured that, in case of conflict, thesysctlparameter wins
Managing user sessions and processes
-
ps -u usernameto show processes owned by a specific user -
pkill -u usernameto remove processes owned by a specific user -
loginctlis a part of systemd, which manages users and sessions -
loginctl list-usersandloginctl list-sessionsshows users and sessions -
loginctl user-status {UID}shows a tree of processes currently opened by this user -
loginctl terminate-sessionandloginctl terminate-usercan be used to stop current sessions or users
Lab Exercise
- Install and enable tuned
- Determine the current and recommended tuned profiles
- Set the tuned profile to the recommended profile
- Create a user mac and open a shell as this user
- As mac, run two background processes
sleep inf, one of them with the highest possible priority, the other one with the lowest possible priority - Use the most efficient way to terminate all current sessions for user mac
Solution
dnf install tuned; systemctl enable --now tunedtuned-adm active; tuned-adm recommendtuned-adm profile $(tuned-adm recommend)useradd macsu mac; sleep inf &; sleep inf &in another terminal windowloginctl terminate-user mac
- Clint Jordan