Linux/Unix Tutorial
Estimated reading: 3 minutes 39 views

⚙️ Linux/Unix: Process & Job Control – ps, jobs, kill, nice, and More

🧲 Introduction – Take Control of Processes in Linux/Unix

In Linux/Unix, process management is a vital skill for every system user and administrator. From monitoring system performance to handling background jobs and adjusting task priorities, understanding how to control processes gives you command over your system.

🎯 In this guide, you’ll learn:

  • How to view running processes with ps, top, and htop
  • How to manage foreground and background jobs
  • How to kill or signal processes safely
  • How to schedule and prioritize processes using nice and renice

📘 Topics Covered

🔵 Subtopic📖 Description
Process Overview (ps, top, htop)View running processes, IDs, memory, and CPU usage
Background & Foreground (jobs, bg, fg)Manage jobs suspended or running in the background
Killing & Signaling (kill, killall, pkill)Terminate processes or send specific signals
Scheduling & Priority (nice, renice, chrt)Adjust CPU priority and scheduling class of processes

🔵 Linux/Unix: Process Overview & Commands (ps, pstree, top, htop)

🔹 ps – Snapshot of Active Processes

ps aux

✅ Shows all processes with user, PID, CPU%, memory usage, and command.


🔹 top – Real-Time Monitoring

top

✅ Live view of processes and system performance. Press q to quit.


🔹 htop – Interactive Alternative to top

htop

✅ Scrollable interface, tree view, kill processes with a keypress.


🔹 pstree – Process Tree View

pstree

✅ Displays hierarchical relationship between processes.


🔵 Linux/Unix: Background & Foreground (jobs, bg, fg, disown)

🔹 Send Job to Background

sleep 100 &

✅ Appends & to run the command in the background.


🔹 List Background Jobs

jobs

🔹 Resume Job in Background/Foreground

bg %1     # Resume job 1 in background
fg %1     # Bring job 1 to foreground

🔹 Disown a Job (Detach from Shell)

disown %1

✅ Removes job from job table to avoid termination on shell exit.


🔵 Linux/Unix: Killing & Signaling (kill, killall, pkill, xkill)

🔹 kill – Send Signal to PID

kill -9 1234

✅ Sends SIGKILL to process with PID 1234.


🔹 killall – Kill by Name

killall firefox

🔹 pkill – Pattern-Based Process Kill

pkill -f "python script.py"

🔹 xkill – Click-to-Kill GUI App (X11 Only)

xkill

🔵 Linux/Unix: Scheduling (nice, renice, chrt)

🔹 nice – Launch Process with Priority

nice -n 10 myscript.sh

✅ Starts with niceness of 10 (lower priority). Default is 0.


🔹 renice – Adjust Priority of Running Process

renice +5 -p 1234

✅ Increases niceness (decreases priority) for process 1234.


🔹 chrt – Set Real-Time Scheduling Policies

chrt -f -p 99 1234

✅ Applies FIFO scheduling policy to PID 1234 with highest priority (99).


📌 Summary – Recap & Next Steps

Linux provides robust tools to monitor, manage, and control processes and jobs. From checking what’s running to adjusting how and when it runs, these tools are essential for resource control, automation, and stability.

🔍 Key Takeaways:

  • Use ps, top, and htop to view and manage running processes.
  • Move jobs between foreground/background with bg, fg, jobs, and disown.
  • Terminate or signal processes with kill, killall, and pkill.
  • Adjust CPU priority using nice, renice, or real-time policies with chrt.

⚙️ Practical Use Cases:

  • Free system memory by killing zombie or rogue processes.
  • Manage long-running background jobs or scheduled scripts.
  • Improve system performance by reprioritizing tasks during heavy load.

❓ Frequently Asked Questions

What’s the difference between kill and killall?
kill targets a specific PID, while killall targets all processes with the given name.


How can I safely close a process without using -9?
✅ Use kill -15 PID (SIGTERM) to allow cleanup before forced termination.


What does nice and renice do?
✅ These control CPU scheduling priority. Lower nice = higher priority.


Can I see all jobs running in the background?
✅ Yes. Run jobs to list background jobs in the current shell.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

⚙️ Linux/Unix: Process & Job Control

Or Copy Link

CONTENTS
Scroll to Top