A user named anil exists on the system and has left rogue processes running in the background. Additionally, a hung task is leaving orphaned resources on the system.
Task
Identify all running processes owned by user anil and terminate them cleanly without deleting the user account.
Ensure no processes associated with the executable name sleep remain active for user anil.
Locate any defunct (zombie) processes running on the system.
Identify the Parent Process ID (PPID) of the zombie process and terminate the parent process so the zombie is fully reaped.
Solution
User Creation & Run Background Process
Create user
sudo useradd anil
Change password
sudo passwd anil
Switch user
su - anil
Run dummy background process
sleep 600 &
Logout
exit
Gently Kill User Process
Find processes owned by a specific user
ps -u anil
Terminate all processes
pkill -u anil
pkill -9 -u anil sleep (Force if needed)
Verify
ps -u anil
Zombie Process
Monitor "zombie" processes
ps aux | grep defunct
Find the zombie process parent PID
ps -o ppid= -p [Zombie process PID]
Example: ps -o ppid= -p 4745
Kill the zombie parent process
kill -SIGTERM [Zombie parent process PID]
Example: kill -SIGTERM 4743
Verify
ps aux | grep defunct
Cleanup
Delete user
sudo userdel -r anil
Your system's database performance requirements dictate a lower memory swappiness value to prefer keeping process pages in RAM rather than moving them to swap.
Task
Configure the system kernel parameter for swappiness (vm.swappiness) to a value of 40.
This configuration must persist across system reboots.
Do not modify system defaults in /etc/sysctl.conf directly; create a custom configuration file named /etc/sysctl.d/10-swappiness.conf.
Load the new configuration immediately without rebooting the server.
Solution
Direct to sysctl.d
cd /etc/sysctl.d/
Create new configuration file in /etc/sysctl.d/
echo "vm.swappiness=40" | sudo tee -a /etc/sysctl.d/10-swappiness.conf
Verify configuration
cat -b 10-swappiness.conf
Apply configuration
sudo sysctl --system
Verify
sysctl vm.swappiness
Cleanup
sudo rm /etc/sysctl.d/10-swappiness.conf
sudo sysctl --system
The server is scheduled to run inside a virtualized hypervisor environment, and performance needs to be optimized for guest virtual machine workloads.
Task
Query the tuning daemon (tuned) to identify the recommended performance profile for this system.
Set the active tuned profile to virtual-guest.
Verify that the profile is active and operational.
Solution
Check status of systemctl
systemctl status tuned
If tuned service not enabled, enabled and start the service : sudo systemctl enable --now tuned
Ask system to recommend a profile
tuned-adm recommend
Change profile
tuned-adm profile virtual-guest
Verify
tuned-adm active
A specialized application suite requires custom kernel tuning along with constrained CPU execution parameters for intensive background tasks.
Task
Create a custom tuned profile named myprofile located in /etc/tuned/profiles/myprofile/.
Configure tuned.conf within this profile to set vm.swappiness = 66 under the [sysctl] directive.
Activate the new profile using tuned-adm and verify that vm.swappiness reflects 66.
Launch a background task copying /dev/zero to /dev/null strictly bound to CPU core 0 with a custom nice value of 10.
Solution
Create new profile directory
mkdir /etc/tuned/profiles/myprofile
Create new configuration file
sudo tee -a /etc/tuned/profiles/myprofile/tuned.conf <<STOP
[sysctl]
vm.swappiness = 66
STOP
Change profile
tuned-adm profile myprofile
Verify active profile
tuned-adm active
Verify swappiness after change profile
sysctl vm.swappiness
Background task
taskset -c 0 nice -n 10 dd if=/dev/zero of=/dev/null &
Verify
ps -o pid,psr,ni,cmd -p [PID]
Example: ps -o pid,psr,ni,cmd -p 4177
Cleanup
jobs ---> fg %[Job Index] ---> Ctrl+C
tuned-adm profile balanced
rm -rf /etc/tuned/profiles/myprofile