Video:How to Use the ps Command on Linuxwith Zoya Popova
The "PS," or process status, command in Linux gives you a snapshot of the processes of your system. In this computer video from About.com, learn the purpose and step-by-step guide how to use the ps command.See Transcript
Transcript:How to Use the ps Command on Linux
Hi, I'm Zoya Popova for About.com, and today I'm going to show you how to use the ps command in Linux.
What is the PS Command in Linux?
"Ps" stands for "process status", and it's a command that gives you a snapshot of the processes in your system. Used by itself, it will only give you information on only two processes: "bash" and "ps" itself.
And note the information you get in the output. It gives you the process ID (PID), the terminal associated with the process (TTY), process time (TIME), and the command that launched the process (CMD). If you want to get information about these four items for all of the processes in your system, you should use the option "-e".
Your PS Command List Will be Lengthy
Your output will be a pretty lengthy list, so in order to view it more easily, you can type the same command (you can do it by simply hitting the "up" arrow), and add "| less": ps -e | less
This will show you the processes screen by screen, and you can go to the next screen by hitting the "space" bar. You can also go a screen back by hitting "b". And when you get to the end of the list, just press "q" to quit.
Another option that you can use is "aux". It will give you information about all the processes in your system that will be more detailed: ps aux | less
Now, instead of the four columns that we had before, we have all this additional information, such as the percentage of CPU (%CPU) and memory (%MEM) used by each process, as well as the column titled "STAT", which shows the status of the process. Most processes have a status starting with "S", which stands for "sleep" and basically means that they are waiting for an event to occur. You also have processes with the status starting with "R", which stands for "running". As you can see, the "ps" process itself has the status "R".
Customizing Your PS Output
Now, you may or may not need all the information listed here, but a great thing about the ps command is that you can actually customize the output. To do that, you have to remember the names of your output columns. Type "ps -eo", followed by the desired output columns separated by a comma. For example, if you'd like to see the process ID, name of the command, percentage of CPU, percentage of memory, and status for each process, type: "ps -eo pid,cmd,%cpu,%mem,stat"
For a detailed description of the ps command, you can always refer to its manual by typing man ps.
Thank you for watching, and for more information, please visit us at About.com.