Introduction
The ps
command is a powerful tool in Linux that allows you to monitor and manage processes on your system. Whether you need to identify a specific process, check the resource usage of a program, or kill a process that's misbehaving, the ps
command has you covered.
Using the ps
Command
At its simplest, the ps
command allows you to view information about the processes running on your system. For example, you can use the ps
command with no options to display a list of all the processes running on your system:
ps
The above command will display a list of all the processes currently running on your system. By default, the ps
command will display the process ID (PID), the terminal associated with the process, the CPU usage, and the command that started the process
Options and Customization
While the basic ps command is useful, there are many options and customization features that you can use to tailor the output to your specific needs. For example, you can use the -e option to display information about all processes on the system, regardless of who owns them:
ps -e
Another useful option is the -f option, which displays a more detailed output that includes the UID, PPID, C, STIME, TTY, and TIME fields:
ps -f
Tips and Tricks
- You can use the
grep
command to search for specific processes. For example, to search for all processes containing the word "chrome", you can use the following command:
ps -ef | grep brave
- You can use the
kill
command to terminate a process. For example, to kill a process with a specific PID, you can use the following command:
kill PID
And you choose the PID number.
- Show all processes with full information:
ps -ef
- Show all processes with full information and a tree-like format:
ps -ejH
- Show all processes with full information and a BSD-style format:
ps axo pid,tt,user,fname,tmout,f,wchan
- Show all processes with full information and display the username and start time:
ps -eo user,pid,ppid,c,start_time,cmd
- Show all processes with full information and display the threads for each process:
ps -eLf
- Show all processes with full information and display the start time and elapsed time for each process:
ps -eo pid,comm,lstart,etime
- Show all processes with full information and sort by memory usage (descending):
ps -e --sort=-rss
- Show all processes with full information and display only the processes owned by a specific user:
ps -u username
- Show all processes with full information and display only the processes with a specific name:
ps -C program_name
- Show all processes with full information and display only the processes with a specific PID:
ps -p PID
- You can use the
top
command to view a dynamic real-time display of the processes running on your system.
Conclusion
The ps command is a powerful and essential tool in Linux for monitoring and managing processes. With its simple syntax and powerful options, you can quickly identify, monitor, and manage processes on your system. Whether you're a system administrator, developer, or power user, the ps command is a must-know tool for efficient Linux management.
Thank you for reading ๐งโ๐ป
Stay tuned for more ๐
โ๏ธ and logout