10 Commands to find the processes in Linux
top : A great commands to find the processes that are using the most CPU. This commands creates self-updating list – and you need to use Ctrl-C to get out of it.
htop : The same thing as top but a little easier to read. It displays the same information with an easier-to-understand layout. htop also lets the user select processes with the arrow keys and perform actions, such as killing them or changing their priority, with the functions keys F1, F2, etc. But for most systems you will have to install this using a command like:
sudo apt-get install htop
ps : simple command to list all running processes but since it can be a long list it is usually best to add a | less so you can page through them or add a grep to look for a particular process name
ps -A | less
ps -A | grep java
pstree : Provides another great way to view your processes. This view allows the user to quickly see which processes spawned other. Great when you have many processes with the same name and you are trying to determine where they came from
pgrep : Is a great short cut to just get back the process id for a given process name.
pgrep java
renice PID : The renice command changes the nice value of an already running process (nice value determines what priority the process runs with 0 being the default and negative number being higher priority than positive numbers). It can be used with pgrep to get the process id of a process by name.
renice 5 $(pgrep java)
kill PID : The kill command is used to end a process given its process ID, which you would have gotten through ps -A, top, pgrep
pkill NAME : Another kill command is used to end a process given its name.
killall NAME : Will kill all prcocess with the given name if more than one is active.
xkill NAME : xkill command is a way of easily killing graphical programs. Run it and your cursor will turn into an x sign. Click a program’s window to kill that program. If you don’t want to kill a program, you can back out of xkill by right-clicking instead.