Managing Processes And Running Applications

I have shown in previous how to's how to use top and my personal favorite htop to list running processes as well as system performance. This how to will delve deeper into the command line tools to modify and stop running processes or programs.


In a command window if you type ps -A it will spit out all the processes running on your system.


You can scroll up or down to see the complete list or pipe the output to `less` ps -A | less to read the output better in a console.


If you know a perticular programs name you can search for it in the output of the above command by using `grep` for example if you wish to find all processes being used by firefox type ps -A | grep firefox in to the console


PSTREE is also a very nice utility and makes it sometimes easier in visually figuring out what processes are running and what is connected to one another. Run pstree in a console and look at the output


Killing a process is sometimes needed if a program hangs or does not respond properly. In order to kill an application you need to know the process ID of that program. If you run ps -A the name of the program is on the far right and the process id of the program is on the far left. Or if you know the name specifically you can use `pgrep`. For example in a console type pgrep firefox. and the output will be the process ID of firefox.


Once you have the process ID you can use kill PROCESSID or sometimes if that does not work you can use kill -9 PROCESSID


You can also run both of those commands together to make it one step instead of two by using kill $(pgrep firefox). Or using `pkill` by typing pkill firefox or using `killall` by typing killall firefox. All of these 3 command will accomplish the same thing...killing off the firefox process


You can change a process/applications priority which may make it run better using `renice`. The nice value determines what priority the process runs with. A value of -19 is very high priority, and in contrast 19 is very low priority. A value of 0 is the default priority that applications run at.


If firefox for instance is chugging a little bit you can give it more of a priorty by typing renice -14 $(pgrep firefox). Be aware that on some distributions you may need sudo access to raise an applications nice value.