Sunday, June 10, 2007

Command Line UNIX

-------------------------------------------------------------------------------------------------------------------------------------------
To check the list of Interrupts (IRQ) you are using :
$ cat /proc/interrupts (Linux)
$echo ::interrupts | mdb -k (Solaris)
-------------------------------------------------------------------------------------------------------------------------------------------
Also see Procinfo, a monitoring utility that interfaces with the Linux /proc file system, and displays data such as
CPU utilization, memory utilization, interrupts serviced and information on the modules that are currently
loaded into the kernel.
$ procinfo -h (For complete list of options)
$procinfo -m (To list Modules and Device Info.)
-------------------------------------------------------------------------------------------------------------------------------------------
Viewing a environment of a Linux or Solaris Process :

On Solaris hosts, you can see the environment of a process by invoking pargs with the "-e" (print the environment) option:

$ pargs -e 18167

18167:  /usr/lib/ssh/sshd envp[0]: LANG=C envp[1]: PATH=/usr/sbin:/usr/bin envp[2]: SMF_FMRI=svc:/network/ssh:default envp[3]: SMF_METHOD=/lib/svc/method/sshd start envp[4]: SMF_RESTARTER=svc:/system/svc/restarter:default envp[5]: TZ=US/Eastern 

On Linux hosts, you can cat /proc/$PID/environ, where $PID is the process id you are interested in:

$ cd /proc/self

$ cat environ

USER=mattyLOGNAME=mattyHOME=/home/mattyPATH=/usr/bin:/bin:/usr/sbin:/sbin MAIL=/var/mail/mattySHELL=/bin/bashSSH_CLIENT=10.10.1.10 49550 22 SSH_CONNECTION=10.10.1.10 49550 10.10.1.11 22SSH_TTY=/dev/pts/0TERM=xterm-color 

The Solaris output is a bit prettier, but they both contain the information you need to derive the environment of a process.

-------------------------------------------------------------------------------------------------------------------------------------------
To view the library calls (specifically malloc and free) ,

$ ltrace /bin/Your-Command

This helps you debug application Problems in Linux.

-------------------------------------------------------------------------------------------------------------------------------------------

Debugging Hung Process :

$pstack PID (Solaris)

$gstack PID (Linux)

This helps to see which stack the application is currently running.

No comments: