How to view Processes

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← What is a Process?HomeSending signal to Processes →

You need to use the ps command, pstree command, and pgrep command to view a snapshot of the current processes.

ps - View process

To view current process use the ps command:

ps
ps aux | less
ps aux | grep "process-name"
ps aux | grep "httpd"
ps alx | grep "mysqld"

pstree - Display a tree of processes

To display a tree of processes use the pstree command:

pstree

Sample outputs:

init─┬─acpid
     ├─apache2───6*[apache2]
     ├─atd
     ├─atop
     ├─avahi-daemon───avahi-daemon
     ├─bonobo-activati───{bonobo-activati}
     ├─console-kit-dae───63*[{console-kit-dae}]
     ├─cron
     ├─2*[dbus-daemon]
     ├─dbus-launch
     ├─dd
     ├─deluge───5*[{deluge}]
     ├─dhclient
     ├─dnsmasq
     ├─evince───{evince}
     ├─firefox───run-mozilla.sh───firefox-bin───27*[{firefox-bin}]
     ├─gconfd-2
     ├─gdm───gdm─┬─Xorg
     │           └─gnome-session─┬─gnome-panel
     │                           ├─gpg-agent
     │                           ├─metacity
     │                           ├─nautilus
     │                           ├─python
     │                           ├─seahorse-agent
     │                           ├─ssh-agent
     │                           ├─tracker-applet
     │                           ├─trackerd───2*[{trackerd}]
     │                           ├─update-notifier
     │                           └─{gnome-session}
     ├─gedit
     ├─6*[getty]
     ├─gnome-power-man
     ├─gnome-screensav
     ├─gnome-settings-───{gnome-settings-}
     ├─gnome-terminal─┬─bash───pstree
     │                ├─bash───ssltx───ssh
     │                ├─gnome-pty-helpe
     │                └─{gnome-terminal}
     ├─gvfs-fuse-daemo───3*[{gvfs-fuse-daemo}]
     ├─gvfs-gphoto2-vo
     ├─gvfs-hal-volume
     ├─gvfsd
     ├─gvfsd-burn
     ├─gvfsd-trash
     ├─hald───hald-runner─┬─hald-addon-acpi
     │                    ├─hald-addon-cpuf
     │                    ├─hald-addon-inpu
     │                    └─hald-addon-stor
     ├─jsvc─┬─jsvc
     │      └─jsvc───39*[{jsvc}]
     ├─klogd
     ├─lighttpd───2*[php-cgi───4*[php-cgi]]
     ├─mixer_applet2───{mixer_applet2}
     ├─mount.ntfs
     ├─mysqld_safe─┬─logger
     │             └─mysqld───10*[{mysqld}]
     ├─netspeed_applet
     ├─ntpd
     ├─pppd───sh───pptpgw
     ├─pptpcm
     ├─pulseaudio─┬─gconf-helper
     │            └─2*[{pulseaudio}]
     ├─squid───squid───unlinkd
     ├─sshproxyd
     ├─syslogd
     ├─system-tools-ba
     ├─thunderbird───run-mozilla.sh───thunderbird-bin───10*[{thunderbird-bin}]
     ├─udevd
     ├─vmnet-bridge
     ├─2*[vmnet-dhcpd]
     ├─vmnet-natd
     ├─3*[vmnet-netifup]
     ├─winbindd───winbindd
     ├─workrave───{workrave}
     ├─workrave-applet
     └─wpa_supplicant

pgrep - Look up processes

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. List the processes called php-cgi AND owned by vivek user.

pgrep -u vivek php-cgi

To list the processes owned by vivek OR krish.

pgrep -u vivek,krish

External links

← What is a Process?HomeSending signal to Processes →