1) ps = report process status
ps : typing ps alone would list the current running processes
ps -u username : to search processes run by a certain user
ps ag : to get information about all running process
ps aux : to display the owner of the processes along with the processes
ps ax | grep processname : to see if a particular process is running or not
.
2) ptree : to display a tree of processeses
pstree -p | less : also display the pid of the process
.
3) pgrep : look up or signal processes based on name and other attributes
pgrep sshd : to list the processes called sshd
pgrep -u root sshd : will only list the processes called sshd AND owned by root
pgrep -u root,daemon : will list the processes owned by root OR daemon
.
4) pidof — find the process ID of a running program
pidof emacs – list the process id for emacs
pgrep and pidof is much the same except that grep is more powerful it has more options (check man pages for both)
.
5) pkill = kill all processes matching the search text
pkill sshd : kill all sshd processes
pkill -9 –u userlogin : kill a process owned by a particular user
.
6) kill = Send a signal to terminate one or more process IDs
kill 2345 : terminate process 2345 (to list process id use ps)
kill -9 2345 : if kill 2345 doesnt work, use kill -9 2345 to force it
.
7) killall = kill all processes by name
killall nautilus
Unlike the kill command, it is not necessary to first try to find the PID(s) for nautilus. And if there are multiple instances of nautilus running, all will be terminated immediately.
killall is similar to pkill