I'm a big fan of procexp and other sysinternals tools on Windows. Many people who use those and then come to Linux complain that there are no such tools in Linux. Most people are familiar with top and ps commands. I would like to introduce you to a bunch of utilities on Linux that are very useful while debugging issues. Lets start with htop, a better alternative to top.
You can install htop on a yum based system like Fedora, Redhat, CentOS etc with "yum -y install htop" or with "apt-get install htop" on systems that are debian apt based like Ubuntu.
htop is much better in displaying the process and resource information than top. It gives a more accurate and clearer picture of process memory usage than top.
A screenshot of htop in action:
It has many interesting features. It's display layout is refreshing different and nice. It can show tree view, a very important feature to understand the ancestry of a process. In the size column, the MB part is highlighted with a different color. The command name in the command line is highlighted. Other user names can be shadowed. You can do multiple process selection and apply nice values or kill them. With the setup menu, you can add or remove the columns, change the color scheme etc. Lots of useful features.
Knowing process hierarchy is very useful in understanding the system. I prefer to use pstree to ps for this reason.
[ root@zen ~]# pstree -nulap
|-dhclient,1597 -1 -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0
|-rsyslogd,1677 -m 0
|-named,1696,named -u named
|-ntpd,1747,ntp -u ntp:ntp -p /var/run/ntpd.pid -g
| |-qmgr,1841,postfix -l -t fifo -u
| |-tlsmgr,1923,postfix -l -t unix -u
| `-pickup,24418,postfix -l -t fifo -u -o content_filter dksign:[127.0.0.1]:10027
| `-freshclam-sleep,24453 /usr/share/clamav/freshclam-sleep
| `-sleep,24455 2829
|-mysqld_safe,12423 /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log--pid-file=/var/run/mysqld/mysqld.pid
| `-mysqld,12483,mysql --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking--socket=/var/lib/mysql
`-memcached,12526,memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
As you can see from the above tree, it is much more clearer as to which process is spawned by which process and helps us to understand the relationships better. Many times, there can be issues due to orphaned child process which are preventing the clean restart of a service. This can be easily identified with pstree.
More tools in next entry.