A process is an instance of a running program. Linux provides multiple utilities to monitor, manage, and control processes effectively. Each process has a unique Process ID (PID) and belongs to a parent process.
ps aux– View all running processesps -u username– View processes for a specific userps -C processname– Show a process by namepgrep processname– Find a process by name and return its PIDpidof processname– Find the PID of a running program
kill PID– Terminate a process by PIDpkill processname– Terminate a process by namekill -9 PID– Force kill a processpkill -9 processname– Kill all instances of a processkill -STOP PID– Stop a running processkill -CONT PID– Resume a stopped processrenice -n 10 -p PID– Lower priority of a processrenice -n -5 -p PID– Increase priority of a process (requires root)
command &– Run a command in the backgroundjobs– List background jobsfg %jobnumber– Bring a job to the foregroundCtrl + Z– Suspend a running processbg %jobnumber– Resume a suspended process in the background
top– Interactive process viewerhtop– User-friendly process viewer (requires installation)nice -n 10 command– Run a command with a specific priorityrenice -n -5 -p PID– Change priority of an existing process
systemctl list-units --type=service– List all system daemonssystemctl start service-name– Start a daemon/servicesystemctl stop service-name– Stop a daemon/servicesystemctl enable service-name– Enable a service at startup
Show processes for a specific user:
ps -u usernameShow a process by name:
ps -C processnameFind a process by name and return its PID:
pgrep processnameFind the PID of a running program:
pidof processnameTo terminate a process by PID:
kill PIDTo terminate using process name:
pkill processnameForce kill a process:
kill -9 PIDKill all instances of a process:
pkill -9 processnameStop a running process:
kill -STOP PIDResume a stopped process:
kill -CONT PIDView process priorities:
top # Look at the NI columnChange priority of a running process:
renice -n 10 -p PID # Lower priority (positive values)
renice -n -5 -p PID # Higher priority (negative values, root required)Run a command in the background:
command &List background jobs:
jobsBring a job to the foreground:
fg %jobnumberSend a running process to the background:
Ctrl + Z # Suspend process
bg %jobnumber # Resume in backgroundInteractive process viewer:
- Press
kand enter a PID to kill a process. - Press
rto renice a process. - Press
qto quit.
A user-friendly alternative to top:
htopAllows mouse-based interaction for process management.
Run a command with a specific priority:
nice -n 10 commandChange the priority of an existing process:
renice -n -5 -p PIDDaemon processes run in the background without user intervention. List all system daemons:
systemctl list-units --type=serviceStart a daemon:
systemctl start service-nameStop a daemon:
systemctl stop service-nameEnable a service at startup:
systemctl enable service-nameProcess management is crucial for system performance and stability. By using tools like ps, top, htop, kill, and nice, you can efficiently control and monitor Linux processes.