The strace is the tool that helps in debugging issues by tracing system calls executed by a program. It is handy when you want to see how the program interacts with the operating system, like what system calls are executed in what order.
This simple yet very powerful tool is available for almost all the Linux based operating systems and can be used to debug a large number of programs.
### 1. Command Usage ###
Let’s see how we can use strace command to trace the execution of a program.
In the simplest form, any command can follow strace. It will list a whole lot of system calls. Not all of it would make sence at first, but if you’re really looking for something particular, then you should be able to figure something out of this output.
Lets see the system calls trace for simple ls command.
raghu@raghu-Linoxide ~ $ strace ls
![Stracing ls command](http://linoxide.com/wp-content/uploads/2014/08/01.strace_ls.png)
This output shows the first few lines for strace command. The rest of the output is truncated.
![Strace write system call (ls)](http://linoxide.com/wp-content/uploads/2014/08/02.strace_ls_write.png)
The above part of the output shows the write system call where it outputs to STDOUT the current directory’s listing. Following image shows the listing of the directoy by ls command (without strace).