Managing processes in Linux is a fundamental skill for system administrators and users. This tutorial covers the usage of ps
, kill
, and jobs
commands to monitor, control, and interact with processes in a Linux environment.
The ps
command provides information about currently running processes. Here are some common options:
ps
This command displays a snapshot of currently running processes in the current terminal.
ps aux
The aux
options display a detailed list of all processes, including those owned by other users.
ps aux | grep "process_name"
You can use grep
to filter processes based on their names.
ps auxf
The f
option shows processes in a tree structure, illustrating parent-child relationships.
The kill
command is used to terminate or signal processes. Here are some common options:
kill PID
Replace PID
with the process ID of the target process.
kill -TERM PID
Use the -TERM
option to send the termination signal (15) to the specified process.
kill -9 PID
The -9
option sends the SIGKILL
signal, forcefully terminating the specified process.
The jobs
command displays a list of current jobs in the shell. Here are some common options:
jobs
This command lists all background jobs associated with the current shell session.
fg %1
Use fg
to bring a job with ID 1 to the foreground. Replace 1
with the job ID displayed by the jobs
command.
bg %1
The bg
command sends job 1 to the background.
Understanding how to manage processes in Linux is essential for maintaining system stability and performance. The ps
command provides insights into running processes, while kill
allows you to terminate or signal them. The jobs
command is useful for monitoring and controlling background jobs. Combine these commands to effectively manage processes in your Linux environment.