frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

List, Check, Stop and Run processes in Linux

EugeneEugene Moderator
edited March 19 in Various Tutorials

Linux is a multi-tasking operating system that efficiently runs multiple processes simultaneously. A process in Linux is essentially a running instance of a program, whether it’s a system service, user application, or background task. Every process has a unique Process ID (PID) and operates within the system’s memory and CPU resources.

Why is process management important?

Monitoring and controlling processes ensures system stability, prevents resource overuse, and helps troubleshoot performance issues. Whether you're diagnosing slowdowns, terminating unresponsive applications, or managing background services, keeping an eye on running processes is essential for maintaining an optimized Linux environment.

Monitoring Processes in the Terminal

Linux provides powerful command-line tools to check, list, stop, and manage processes effectively. These commands offer detailed insights into system activity, allowing users to interact with processes directly from the terminal.
Here are some of the most commonly used commands for process management:
· ps – Displays currently running processes.
· top / htop – Provides a real-time view of system processes, including CPU and memory usage.
· pgrep – Searches for processes by name.
· pidof – Retrieves the PID of a running process.
· kill, killall, pkill – Terminates processes using their PID or name.
· nice / renice – Adjusts process priority.
· nohup / disown – Keeps processes running after logout.
· jobs / fg / bg – Manages background and foreground tasks.
Let’s deep down and review the commands:

The ps command
The ps command in Linux displays information about currently running processes, including their Process ID (PID), user, CPU usage, and more. It is useful for monitoring active tasks and identifying processes for management or troubleshooting.
· ps aux – Lists all running processes with detailed information.
· ps -ef – Displays processes in a full-format listing.
· ps -u username – Shows processes owned by a specific user.
· ps -p PID – Displays details of a specific process by its PID.
Every column has it’s unique meaning. We will look more deeply for the ps aux command

· USER – The owner of the process.
· PID – The Process ID.
· %CPU – CPU usage percentage.
· %MEM – Memory usage percentage.
· VSZ – Virtual memory size in kilobytes.
· RSS – Resident Set Size (physical memory used).
· TTY – Terminal associated with the process (if any).
· STAT – Process state (e.g., R = running, S = sleeping).
· START – Start time of the process.
· TIME – CPU time used by the process.
· COMMAND – The command that started the process.

By understanding each of the column, you can identify every process and it’s location on your server.

The top command
The top command in Linux provides a real-time, dynamic view of system processes, displaying resource usage such as CPU, memory, and running tasks. It helps monitor system performance and allows users to manage processes directly from the interface.
· top – Displays real-time process monitoring.
· htop– Same as top but in a more friendly UI.
· top -u username – Shows processes for a specific user.
· Press k inside top – Prompts to kill a process by PID.
· Shift + M – Sorts processes by memory usage.
· Shift + P – Sorts processes by CPU usage.
· Shift + E– Changes values in KiB, MiB, GiB, TiB ....

The pgrep command
The pgrep command in Linux searches for running processes by name and returns their Process IDs (PIDs), making it easier to locate specific processes without manually filtering through ps output. It supports pattern matching, user-based searches, and case-insensitive lookups for efficient process management.
· pgrep apache2 – Finds the PID of the apache2 process.
· pgrep -u root – Lists PIDs of all processes owned by the root user.
· pgrep -l ssh – Displays PIDs along with process names for ssh.
· pgrep -f "python script.py" – Searches for processes including full command-line arguments.

The pidof command
The pidof command in Linux retrieves the Process ID (PID) of a running program by its exact name, making it useful for quickly identifying a process without extra output. Unlike pgrep, it only returns PIDs and does not support pattern matching.
· pidof nginx – Gets the PID of the nginx process.
· pidof -s firefox – Returns only the first (single) PID of firefox.
· pidof -x script.sh – Finds the PID of a script, including those run with bash script.sh.

The kill, killall, pkill commands
The kill command in Linux terminates a process using its Process ID (PID), while killall stops all processes matching a given name. Both commands support different signals to gracefully stop, restart, or forcefully terminate processes. The pkill command in Linux terminates processes by name, similar to killall, but allows pattern matching and filtering by user, session, or other attributes
· kill 1234 – Sends the default SIGTERM signal to terminate process with PID 1234.
· kill -9 5678 – Forcefully kills process 5678 using SIGKILL.
· killall firefox – Terminates all running instances of firefox.
· killall -s HUP nginx – Sends a SIGHUP signal to restart all nginx processes.
· pkill firefox – Kills all firefox processes.
· pkill -u root nginx – Stops all nginx processes running under the root user.
· pkill -f "python script.py – Kills a process based on its full command-line arguments.

The nice / renice commands
The nice command in Linux starts a process with a specified priority, while renice adjusts the priority of an already running process. Lower nice values give higher priority, and higher values make the process run with lower priority, helping manage system resource allocation.
· nice -n 10 ./script.sh – Runs script.sh with a lower priority (nice value 10).
· renice -5 -p 1234 – Increases the priority of process 1234.
· renice 15 -u user1 – Lowers the priority of all processes owned by user1.
· nice --10 make – Runs make with a high priority (-10 nice value).

The nohup / disown commands
The nohup command in Linux runs a process immune to hangups, ensuring it continues executing even after the user logs out. The disown command detaches a running job from the current shell, preventing it from being terminated when the shell session ends.
· nohup ./script.sh & – Runs script.sh in the background and prevents termination on logout.
· nohup command > output.log 2>&1 & – Runs a command and redirects output to output.log.
· disown -h %1 – Detaches job 1 from the shell but allows it to keep running.
· disown -a – Detaches all background jobs from the current session.

The jobs, fg and bg commands
The jobs command in Linux lists background jobs running in the current shell session, while fg brings a background job to the foreground, and bg resumes a paused job in the background. These commands help manage job control and allow users to interact with processes without closing or terminating them.
· jobs – Displays a list of current background jobs.
· fg %1 – Brings job 1 to the foreground.
· bg %2 – Resumes job 2 in the background.
· fg – Brings the most recent background job to the foreground.

In this guide, we've explored essential Linux commands for managing processes, including checking, listing, stopping, and running tasks. By understanding commands like ps, top, kill, pgrep, and others, you can efficiently monitor system resources, control processes, and maintain an optimized Linux environment.

Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2025 Time4VPS. All rights reserved.

Get In Touch