Hoe to view running processes in Linux

0

 Running a command results in something called a process. In the Linux operating system, processes are executed with the privileges of the user who executes the command. This allows for processes to be limited to certain capabilities based upon the user identity.

Although there are exceptions, generally the operating system will differentiate users based upon whether they are the administrator. Typically regular users, like the sysadmin user, cannot control another user's processes. Users who have administrative privileges, like the root account, can control any user processes, including stopping any user process.

The ps command can be used to list processes.

ps [OPTIONS]
sysadmin@localhost:~$ ps
  PID TTY          TIME CMD
   80 pts/0        00:00:00 bash
   94 pts/0        00:00:00 ps

The ps command will display the processes that are running in the current terminal by default. In the example above, the bottom line is the process created by the execution of the ps command. The output includes the following columns of information:

  • PID: The process identifier, which is unique to the process. This information is useful for controlling the process by its ID number.

  • TTY: The name of the terminal where the process is running. This information is useful for distinguishing between different processes that have the same name.

  • TIME: The total amount of processor time used by the process. Typically, this information isn't used by regular users.

  • CMD: The command that started the process.

Instead of viewing just the processes running in the current terminal, users may want to view every process running on the system. The -e option will display every process:

sysadmin@localhost:~$ ps -e
  PID TTY          TIME CMD                                                     
    1 pts/0        00:00:00 init                                                    
   33 ?            00:00:00 rsyslogd                                                
   37 ?            00:00:00 cron                                                    
   39 ?            00:00:00 sshd                                                    
   56 ?            00:00:00 named                                                   
   69 pts/0        00:00:00 login                                                   
   79 pts/0        00:00:00 bash                                                    
   94 pts/0        00:00:00 ps 

Typically, the -f option is also used as it provides more detail in the output of the command, including options and arguments. Look for the ps command on the last line, the CMD column now includes the options used:

sysadmin@localhost:~$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD                             
root         1     0  0 19:16 pts/0        00:00:00 /sbin??? /init                  
syslog      33     1  0 19:16 ?            00:00:00 /usr/sbin/rsyslogd              
root        37     1  0 19:16 ?            00:00:00 /usr/sbin/cron                  
root        39     1  0 19:16 ?            00:00:00 /usr/sbin/sshd                  
bind        56     1  0 19:16 ?            00:00:00 /usr/sbin/named -u bind         
root        69     1  0 19:16 pts/0        00:00:00 /bin/login -f                   
sysadmin    79    69  0 19:16 pts/0        00:00:00 -bash                           
sysadmin    95    79  0 19:43 pts/0        00:00:00 ps -ef

Post a Comment

0Comments
Post a Comment (0)