Investigating What a Process is Actually Doing in Linux With strace

By | January 6, 2014

If you need to debug a process in a linux environment, the simplest yet very effective solution should be strace.
It can be easily installed with “yum install strace” or “apt-get install strace” depending on the type of Linux you’re on.

Here are some usage samples.

First of all, if you don’t have a shortcut to strace, you should find the path where it resides. Type whereis strace. You should get something like this:

Then use the path you get to find out what a process is actually doing. Type top, your output should look like:

In order to investigate a process, type  /usr/bin/strace -p6971 (in this sample 6971 is the process ID, you should enter yours).
You can also redirect the process output to a file.


This will send strace output to a file until the strace process in interrrupted.

There are lots of additional parameters strace uses. I have mentioned only the most simple ones, you’re welcome to discover all other option to get the output you need.

Leave a Reply

Your email address will not be published. Required fields are marked *