Using system tools – strace
When running any command or program on our Linux machine, you might wonder what the background working of it is. For this, we have a very useful tool in Linux called strace.
This a command-line tool that can be also used as a diagnostic or debugging tool. strace monitors the interaction between processes and the Linux kernel and is helpful when we want 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 this output:In the preceding screenshot, the output displayed has been truncated. If we check the last few lines of the output, we see some write system calls...