Listing Running Processes
To list all the running processes on a Linux system, you can use various commands. The most common commands are ps
(process status) and top
.
Using the ps
Command
The ps
command is a powerful tool for listing running processes. It provides a snapshot of the current processes and their details. Here's how you can use it:
## List all running processes
ps -ef
## List processes owned by the current user
ps -u
## List processes in a tree-like format
ps -ejH
The output of the ps
command includes information such as the process ID (PID), the user who owns the process, the command that started the process, and the CPU and memory usage.
Using the top
Command
The top
command provides a real-time view of the running processes on your system. It displays the processes sorted by CPU or memory usage, making it easier to identify resource-intensive processes. Here's how you can use it:
## Run the top command
top
The top
command provides a dynamic and interactive interface, allowing you to sort, filter, and perform various actions on the running processes.
Customizing the Output
Both the ps
and top
commands allow you to customize the output to display specific information. You can use various options and flags to tailor the output to your needs. For example:
## Display specific columns in the ps output
ps -eo pid,user,comm,%cpu,%mem
## Sort the top output by memory usage
top -o %MEM
By understanding these commands and their options, you can effectively list and monitor the running processes on your Linux system.