How often you check for the running processes on your Ubuntu system? The basic need to do is to know about the process ID (PID), memory utilization, etc. With the help of PID you can easily kill a process whichever is no longer needed or stopped unexpectedly.
Various commands are available to look at the running processes, but its usage may vary according to the requirement, they are as follows:
- ps: The ps command is used to show status of the processes in a single snapshot. It gives an overall CPU utilization within the lifetime of a process.
Syntax to use: “ps” or “ps [options]” - pstree: This command will give you the same result as “ps”, but it differs in the way the information is displayed. “Pstree” will list the processes in a hierarchical way and in a tree like structure. And the other difference is that, it lists the data in alphabetical order, whereas “ps” shows the processes in the order they were created.
Syntax to use: “pstree [options] [username or pid] OR “pstree” - top: This command gives you the information of most active processes in the system. The information changes in every 5 seconds. As compared to “ps”, the top command will display only the current CPU utilization.
Syntax to use it: “top” - htop: It is the modified form of “top”. To use this command you have to install it firstly. It provides convenient result about resource utilization in addition to “top” command.
Our task to see, which processes are running will get accomplished using the first two commands only, so there is no need to install the fourth one.
In this article, we”ll discuss about how to show running processes in Ubuntu, and for that you need to be patient, while looking at the output of each command as shown below.
Steps to Show Running Processes in Ubuntu
Step 1: Let’s start with “ps [options]” command. Firstly, I will use “ps ux” where “ux” is one of the defined option. Here, “u” is used to display the user processes which means only the current user and “x” is for the processes having no controlling terminal, which starts during the system booting.
Step 2: Output of the above command is shown in the figure below. You may notice here, only the processes of user named “ubuntu14” is displayed. There are various parameters stated such as user, pid, %cpu, etc.
USER: It means the name of the user corresponding to the process
PID: It is an abbreviation for “process identification number”. Every process has its unique process ID.
%CPU: It will display the CPU time divided by the time of the process since it is running.
%MEM: It describes the ratio of real memory size occupied by a process to the physical memory on the machine.
VSZ: It shows the virtual memory usage by the process.
RSS: It stands for Resident Set Size that means, the memory allocated to the process including the stack and the heap memory.
TTY: Previously known as “teletype” but now called as the Terminal Type in which the user has logged on.
STAT: It states the file attributes of an index node.
START: Shows the starting time of the process.
TIME: Shows the CPU time measured in minutes & seconds.
COMMAND: States command along with arguments.
Step 3: If you want to display the process of all the users, then use “ps aux” command, where ‘a’ is used to look at processes of all users and the rest is same as discussed above.
Step 4: The attributes of the “ps aux” will be same as in the “ps ux” command. However, it will display the processes of all the users including the root user also.
Step 5: In addition to a root, the user “ubuntu14” processes are also listed as you can see in the figure below.
Step 6: If you are interested in knowing only about the process without a username, CPU and memory utilization then type “ps -e” command, so as to have a short information about the processes.
Step 7: The above command will result in “PID, TTY, TIME & CMD” only. CMD describes the name of the command, that initiated that process as shown below.
Step 8: Command, which you have used earlier has resulted in a fewer attributes associated with the PID. If looking for a full list with Parent PID, then use the “ps -ef” command.
Step 9: “ps -ef” shows other attributes in addition to “ps -e”, such as PPID, it is Parent Process ID.
From this output, you may have understood, why the list of processes is so long. As a single parent process has a large number of child processes, as illustrated in the figure below.
Step 10: Now, move on to the “pstree” command that is used to clearly understand the relation between the processes.
Just type “pstree” command or use it with any of the [options]. I have used only “pstree” to list all the processes.
Step 11: Here, you will come across the actual relation between the parent and child process. In all the previous commands, you may figure out “init” listed on the top. If not, then scroll to the top.
In this figure also, “init” is clearly mentioned. “Init” is the ancestor of all the processes in the Linux system in general, that’s why it always appears at the top.
NOTE: To have a compact view of all the running processes, so that it may be captured on a single screen, use “less” with the commands elucidated above.
For an example: “pstree | less”
Leave a Reply