View running processes on a Linux system
Anyone that has used a Windows Operating System should be familiar with Task Manager, the program that allows you to end processes and to view a dynamic display of your computer's performance. For those making the switch over to Linux here are the alternatives to Task Manager.
First lets start with an introduction to the ps (process status) command. This is used to display information on active processes, including their process identification numbers (PIDs). A process, also referred to as a task, is an executing (running) instance of a program. Every process is assigned a unique PID by the system and you can killing a Linux process by referencing these PIDs.
With escalated privileges type the following in your terminal window to show active processes on the system. As the list of processes can be quite long and occupy more than a single screen, the output of ps aux can be piped (transferred) to the less command, which lets it be viewed one screen full at a time. The output can be advanced one screen forward by pressing the SPACE bar and one screen backward by pressing the b key.
The a option tells ps to list the processes of all users on the system rather than just those of the current user, with the exception of group leaders and processes not associated with a terminal. A group leader is the first member of a group of related processes.
The u option tells ps to provide detailed information about each process. The x option adds to the list processes that have no controlling terminal, such as daemons, which are programs that are launched during boot and run unobtrusively in the background until they are activated by a particular event or condition.
ps aux | less
Output will be similar to this:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 1992 708 ? Ss Jan01 0:00 init  root 2 0.0 0.0 0 0 ? S Jan01 0:00 [migration/0] root 3 0.0 0.0 0 0 ? SN Jan01 0:00 [ksoftirqd/0] root 4 0.0 0.0 0 0 ? S Jan01 0:00 [watchdog/0] root 5 0.0 0.0 0 0 ? S< Jan01 0:00 [events/0] root 6 0.0 0.0 0 0 ? S< Jan01 0:00 [khelper] root 9 0.0 0.0 0 0 ? S< Jan01 0:00 [xenwatch] root 10 0.0 0.0 0 0 ? S< Jan01 0:00 [xenbus] daemon 1506 0.0 0.0 1924 436 ? Ss Jan01 0:00 /usr/sbin/atd root 1526 0.0 0.1 2044 888 ? Ss Jan01 0:00 /usr/sbin/cron user 9381 16.5 15.0 700080 389304 ? Sl Jan01 489:30 /usr/lib/firefox-x.x/firefox www 28284 0.6 4.5 70036 23972 ? R 09:51 0:09 /usr/sbin/apache2 -k start www 28402 0.7 3.9 69620 20944 ? S 09:59 0:07 /usr/sbin/apache2 -k start user 28435 0.7 3.9 69600 20732 ? S 10:06 0:04 /home/user/linuxlookup.pl
Htop is an advanced, interactive system monitor process viewer written for Linux. It is designed to replace the Unix program top. It shows a frequently updated list of the processes running on a computer, normally ordered by the amount of CPU usage and sort based on other criterias. Use your preferred package manager to install Htop or see the official homepage linked at the bottom of this article for download options.
The pstree command is similar to ps in that it can be used to show all of the processes on the system along with their PIDs. However, it differs in that it presents output in a tree structure that shows how processes are related to each other and in that it provides less detailed information about each process than does ps.
Most Desktop environments offer a GUI Task Manager for those of you partial to graphical interfaces. For example, Ubuntu by default uses the Gnome Desktop environment and the Linux Task Manager can accessed by clicking System > Administration > System Monitor. Though a GUI may be the most simplistic, you really should take some time to learn to use command line options.