Managing Processes

Nov 9, 2025

Using signals to manage process state

man 7 signal
  • The kill command is used to send signals to PIDs
    • Alternatively, you can use k from top
  • Different kill-like commands exist, like pkill and killall

Priority management

Wikipedia - control groups

Note: for RHCSA, only nice and renice is needed

  • If processes are equal from a perspective of Cgroups, the Linux nice and renice commands can be used to manage priority
  • nice values 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/sys directory in the /proc pseudo file system
  • Change the current value by echoing a new value into the file
    • cat /proc/sys/vm/swappiness
    • echo 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 list shows current profiles
  • tuned-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=1 parameter in /etc/tuned/tuned-main.conf ensured that, in case of conflict, the sysctl parameter wins

Managing user sessions and processes

  • ps -u username to show processes owned by a specific user

  • pkill -u username to remove processes owned by a specific user

  • loginctl is a part of systemd, which manages users and sessions

  • loginctl list-users and loginctl list-sessions shows users and sessions

  • loginctl user-status {UID} shows a tree of processes currently opened by this user

  • loginctl terminate-session and loginctl terminate-user can be used to stop current sessions or users

Lab Exercise

  1. Install and enable tuned
  2. Determine the current and recommended tuned profiles
  3. Set the tuned profile to the recommended profile
  4. Create a user mac and open a shell as this user
  5. As mac, run two background processes sleep inf, one of them with the highest possible priority, the other one with the lowest possible priority
  6. Use the most efficient way to terminate all current sessions for user mac
Solution
  1. dnf install tuned; systemctl enable --now tuned
  2. tuned-adm active; tuned-adm recommend
  3. tuned-adm profile $(tuned-adm recommend)
  4. useradd mac
  5. su mac; sleep inf &; sleep inf & in another terminal window
  6. loginctl terminate-user mac

- Clint Jordan