Lab 11: Process and Service Management

Listing processes

#To list all currently running processes with all information
ps -el

#To list currently currently running processes with user, PID, PPID, terminal, command.
ps –eLf
ps –efH
ps  –eo  user,pid,ppid,tty,command
pstree

To kill a process

#To kill a program
kill <PID>      

#To kill a program immediately
kill  -9  <PID>

#To kill process by name
pkill  <NAME>

#To kill all processes with given name
killall   <NAME>

Managing services using systemctl command

#During run-time
systemctl  start <SERVICENAME> 
systemctl  stop <SERVICENAME> 
systemctl  restart  <SERVICENAME> 
systemctl  status  <SERVICENAME> 

#At start-up
systemctl  enable  <SERVICENAME> 
systemctl  disable  <SERVICENAME>

Run-level commands

#To check current runlevel
runlevel

#To change systemctl runlevel
init <0-6>