Check Processes by process ID

To view the process by their process id we need to execute the ps command, separated by option -p with process id. 

Syntax : 

ps -p (process id)  

Shell Script : 

#!/bin/bash 
function ProCheck() 
{
ps -p 640
ps -p 675 
}
ProCheck() 

Output : 

Shell Scripting – How to view Processes?

In this article, let’s explore how we can view current processes running on a Linux Server. 

Linux machine gives users the option of multitasking hence naturally there will be multiple processes running on a session and also these processes are important fundamental components of Linux OS, Hence System Administrators may need to be aware of all processes and on what terminals they are running. For getting the list of all processes running on the machine, Linux gave a utility called ps, which provides the information of processes running on the Machine, here ps stands for Process Status.  

Syntax : 

ps {options} 

The outcome generated by the ps command contains 3 fields namely : 

  • PID: This is the unique id associated with each process. 
  • TTY: This Value defines the type of terminal the user is using. 
  • CMD: This value defines the name of the command by which the process got launched. 

Now let us see different types of ps commands that can be executed on a Linux Server with running example scripts running those commands. 

Similar Reads

Check processes that run in the current shell

We use the ps command to see the currently running processes in the shell....

Check all running processes in the Terminal

To view all the running processes in the terminal, we use the ps command followed by -A or -e. Shell script to View all running processes in Terminal...

Check processes that are not associated with a terminal

Run command ps separated with option -a to see the processes which are not associated with the terminal on a Linux Machine....

Check all processes except those of session leaders

For viewing processes except for session leaders, execute command ps separated with option -d...

Check Processes that are session Leaders

Execute command ps separated with options -a -N to get the list of processes that are only session leaders....

Check Process by list

We can view the processes by listing the index by executing the ps command separated by ps separated by -p with a list of index numbers....

Check all processes that belong to Terminal

We can execute the ps command separated by -T to get the list of processes that belong to the terminal....

Check Processes by process ID

To view the process by their process id we need to execute the ps command, separated by option -p with process id....

Check processes by command

To display processes with reference to the command we used, we can execute command ps separated by option -c with the command we desire to display....