Skip to content

Latest commit

 

History

History
105 lines (62 loc) · 2.56 KB

01.Managing_processes (ps, kill, jobs).md

File metadata and controls

105 lines (62 loc) · 2.56 KB

Managing Processes in Linux

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.

ps Command - Process Status

The ps command provides information about currently running processes. Here are some common options:

Basic Usage

ps

This command displays a snapshot of currently running processes in the current terminal.

Displaying Detailed Information

ps aux

The aux options display a detailed list of all processes, including those owned by other users.

Filtering Processes

ps aux | grep "process_name"

You can use grep to filter processes based on their names.

Displaying Tree Structure

ps auxf

The f option shows processes in a tree structure, illustrating parent-child relationships.

kill Command - Terminating Processes

The kill command is used to terminate or signal processes. Here are some common options:

Terminating a Process by PID

kill PID

Replace PID with the process ID of the target process.

Sending a Specific Signal

kill -TERM PID

Use the -TERM option to send the termination signal (15) to the specified process.

Forcing Termination

kill -9 PID

The -9 option sends the SIGKILL signal, forcefully terminating the specified process.

jobs Command - Monitoring Background Jobs

The jobs command displays a list of current jobs in the shell. Here are some common options:

Listing Jobs

jobs

This command lists all background jobs associated with the current shell session.

Bringing a Job to the Foreground

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.

Sending a Job to the Background

bg %1

The bg command sends job 1 to the background.

Conclusion

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.