The following commands are useful when trying to troubleshoot issues on our J2EE servers. This is for Red Hat Linux, but some of these commands are generally applicable to other versions of Linux and Unix as well. This is by no means a full tutorial on Linux administration, just some quick stuff for a guy doing basic troubleshooting.
top - memory and CPU utilization of various processes.
lsof - List open file descriptors
file – shows what type a file is
ps – shows processes and their id’s, children and parent id’s
netstat – shows ports and connections status, e.g. netstat –a to show all connections.
ipcs – show shared memory info
nice, renice – change the run priority for a process
sudo – run a process as the root or other privileged user
who –r – shows current run-level of machine
kill - everyone knows the basics of kill, interupts a process with a signal you specify. kill -l to list the signals, kill –3 for instance is stack trace, kill –9 really kills the process dead.
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE
9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGURG
17) SIGSTOP 18) SIGTSTP 19) SIGCONT 20) SIGCHLD
21) SIGTTIN 22) SIGTTOU 23) SIGIO 24) SIGXCPU
25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH
29) SIGLOST 30) SIGUSR1 31) SIGUSR2