Using System tools – strace
When running any command or program on our Linux machine, we might wonder what the background working of it is. For this, we have a very useful tool in Linux called strace
.
It's a command-line tool which can be also used as a diagnostic or debugging tool. Strace monitors the interaction between the processes, and the Linux kernel and is helpful when we would like to debug the execution of any program.
Getting ready
This tool is available for all Linux-based systems by default. Hence, nothing else needs to be configured to start using strace
.
How to do it...
Let's see how strace can be used in various ways to trace the execution of any program, from start to end:
- To trace the execution of any executable command in Linux, simply run the
strace
command followed by the executable command. If we usestrace
for thels
command, we get the following output:
- In the preceding screenshot, the output displayed has been truncated. If we check the last few lines of the output, we...