Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the strace and ltrace commands. They provide information on the system and library calls that a Linux process makes and this information can help when you’re troubleshooting a process that’s not behaving as you’d expect. You will likely have to install these commands.
As you can see, the pwd command makes a number of system calls (e.g., access and openat). You can also trace its system calls in summary mode like this:
Ordered by the time spent on each of the system calls. You cannot redirect the output of either command, but you can send the output to a file like this:
The ltrace command uses the same syntax, but looks at library calls. So, you can run commands like these:
That’s your Linux tip for strace and ltrace.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
previous post