ps Command in Linux
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreOverview
The ps command in Linux is a powerful tool for displaying information about running processes on your system. It allows you to view detailed information about the processes, including their resource usage, process IDs, and much more. In this article, we will explore the ps command in detail and learn how to use it effectively.
Linux ps Command Syntax
The syntax for the ps command is as follows:
Where:
- Options: The various options available with the ps command
ps Command Options:
- -a: Show processes for all users
- -u: Display user-oriented format
- -x: Include processes that do not have a controlling terminal
- -e: Show information about all processes
- -f: Display a full listing of processes with additional information
Example Usages
-
Viewing all running processes:
Output:
Explanation: This command displays a list of all running processes on the system. The output shows the process ID (PID), the terminal or pseudo terminal associated with the process (TTY), the amount of CPU time consumed by the process (TIME), and the command that started the process (CMD).
-
Viewing processes for all users:
Output:
Explanation: The -e option shows information about all processes, while the -f option provides a full listing of processes with additional information. The UID field displays the user ID of the owner of the process, while the PPID field shows the parent process ID. The C field displays the CPU utilization of the process, and the STIME field shows the start time of the process. The CMD field displays the command that started the process.
-
Viewing detailed process information:
Output:
Explanation: The aux options together provide a lot of detailed information about running processes, including the percentage of CPU and memory used by each process, the virtual memory size (VSZ) and resident set size (RSS) of each process, and the process state (STAT). The START field shows the start time of the process, and the TIME field shows the CPU time consumed by the process.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
To sort the output of the ps command by CPU usage, use the ps aux --sort=-%cpu command.
-
To display information about threads associated with each process, use the ps -eLf command.
-
To display processes in a tree-like format, use the ps axjf command.
Advanced Use Cases of ps Command in Linux
-
Displaying only specific processes:
Output:
Explanation: This command displays only the process specified by its process ID (PID). Replace <pid> with the actual process ID.
-
Displaying parent process information:
Output:
Explanation: This command displays the parent process of a specified process. Replace <pid> with the process ID of the child process, and <ppid> with the parent process ID.
-
Displaying the processes running on a specific terminal:
Output:
Explanation: This command displays the processes running on the specified terminal. Replace <tty> with the terminal name.
Turn Learning into Career Growth
Conclusion
-
The ps command is a powerful tool for displaying information about running processes on your Linux system.
-
The ps command can display detailed information about the processes, including their resource usage, process IDs, and much more.
-
By using various options with the ps command, you can view specific information about running processes that is relevant to your needs.
-
The ps command can be used to monitor and troubleshoot system performance issues, and it is a valuable tool for system administrators and developers.