strace for debugging Linux apps

The strace command is a terrific tool for debugging application issues on Linux. More below.


The strace command on Linux, like its cousin, truss on Solaris, can be very useful in tracking down exactly what is going wrong with a particular command or daemon.

Like truss, the strace command has a number of options that are worth becoming familiar with.

Basic operation of strace is simple:

strace /usr/sbin/httpd

In most cases you’ll want to generate a file to capture the output for more detailed analysis:

strace -o strace.out /usr/sbin/httpd

Because many daemons fork additional processes, the “-f” option is also recommended:

strace -o strace.out -f /usr/sbin/httpd

To check a running process, use the “-p” option with the process number:

strace -o strace.out -fp 48511

When using this last mode you’ll need to CNTRL-c to exit tracing.