To see which processes are currently on a system, most people use the “ps” and “top” commands. The “ps” command gives you a snapshot (in a single list) of processes running at the moment. The “top” command offers a screen oriented, constantly updated listing of running commands, sorted as you choose ( by CPU, memory, UID, etc).
ps #List processes of current user at current shell
root@ubuntu-box:~# ps PID TTY TIME CMD 2988 pts/0 00:00:00 su 2996 pts/0 00:00:00 bash 3047 pts/0 00:00:00 ps
ps -u jorge #Show all jorge’s running processes
root@ubuntu-box:~# ps -u jorge PID TTY TIME CMD 2662 ? 00:00:00 x-session-manag 2725 ? 00:00:00 VBoxClient 2730 ? 00:00:00 VBoxClient 2737 ? 00:00:00 VBoxClient 2748 ? 00:00:00 ssh-agent
ps -u jorge u #Show all running processes with CPU/MEM
root@ubuntu-box:~# ps -u jorge u USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND jorge 2662 0.1 1.3 26392 7100 ? Ssl 02:17 0:00 x-session-manag jorge 2725 0.1 0.3 5736 1772 ? Sl 02:17 0:00 /usr/bin/VBoxCl jorge 2730 0.0 0.2 5608 1148 ? Sl 02:17 0:00 /usr/bin/VBoxCl jorge 2737 0.0 0.2 5608 1196 ? Sl 02:17 0:00 /usr/bin/VBoxCl jorge 2748 0.0 0.1 4784 600 ? Ss 02:17 0:00 /usr/bin/ssh-ag
ps -e #show every running process
root@ubuntu-box:~# ps -e
PID TTY TIME CMD
1 ? 00:00:00 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 migration/0
4 ? 00:00:00 ksoftirqd/0
5 ? 00:00:00 watchdog/0ps aux #show every running process BSD style
root@ubuntu-box:~# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.2 0.3 3084 1888 ? Ss 02:17 0:00 /sbin/init root 2 0.0 0.0 0 0 ? S< 02:17 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S< 02:17 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S< 02:17 0:00 [ksoftirqd/0]
ps -ef –forest #show process hierarchy in forest format
root@ubuntu-box:~# ps -ef --forest UID PID PPID C STIME TTY TIME CMD 111 2139 1 0 02:17 ? 00:00:00 /usr/sbin/hald root 2205 2139 0 02:17 ? 00:00:00 \_ hald-runner root 2235 2205 0 02:17 ? 00:00:00 \_ hald-addon-input: Listening on root 2271 2205 0 02:17 ? 00:00:00 \_ hald-addon-storage: polling /de root 2272 2205 0 02:17 ? 00:00:00 \_ hald-addon-storage: no polling 111 2276 2205 0 02:17 ? 00:00:00 \_ hald-addon-acpi: listening on
ps -C sshd #display running sshd process
root@ubuntu-box:~# ps -C sshd PID TTY TIME CMD 2103 ? 00:00:00 sshd
or this method using “grep” give the same result
ps -e | grep sshd #display running sshd process
root@ubuntu-box:~# ps -e | grep sshd 2103 ? 00:00:00 sshd
Now if you want to see process running in your system live, you can use the “top” command.
Here are some examples:
top -d 5 #changes update delay to 5 seconds instead of 3 (default)
top -u username #only display processes for that user
top -p 223, 5632 #only display processes 223, 5632