Troubleshooting with strace

Best Practices for System Tracing

To get the most out of system tracing, keep the following best practices in mind when using strace:

  1. Filter what you trace. Use -e trace=... to focus on relevant system calls.
  2. Follow child processes. Use -f to trace across process boundaries.
  3. Control output verbosity. Use -v for more details or -e abbrev=... to reduce output.
  4. Save output for analysis. Use -o file.txt to save traces for later review.
  5. Consider performance impacts. Tracing adds overhead; be careful on production systems.
  6. Combine with other tools. Use dmesg, logs, and other diagnostics alongside tracing.

Conclusion

System tracing with tools like strace provides visibility into the critical interface between applications and the Linux kernel. As you have seen in these four scenarios, this visibility can help diagnose a wide range of issues – from missing files to memory problems, from crashes to performance bottlenecks.

By understanding the system calls your applications make, you gain insights that would be difficult or impossible to obtain through other means. This knowledge allows you to solve problems more efficiently and design more robust, performant software.

The next time you face a mysterious Linux issue, remember to reach for strace and its tracing cousins. The system call interface reveals the truth about what's really happening in your system.

The Author

Ajinkya Kadam is a Senior Site Reliability Engineer with over 10 years of experience designing and maintaining highly resilient, high-traffic infrastructure. He specializes in Linux performance analysis, troubleshooting, and applying advanced tracing techniques to solve complex production issues.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Practical strace

    After "Hello World," you really need to look at system calls in more detail. In this second of two articles, we'll look at debugging in the real world.

  • strace

    Get started with strace by examining a pair of "Hello World" programs. Next month, in the second part of this two-part series, I'll take a deeper look at strace output.

  • strace and Firejail

    Software from unknown sources always poses some risks. With the strace analysis tool and the Firejail sandbox, you can monitor and isolate unknown applications to safeguard your system.

  • Core Technologies

    Ever wondered what processes are currently doing on your system? Linux has a capable mechanism to answer your questions.

  • LD_PRELOAD

    A little C code and the LD_PRELOAD variable let you customize library functions to modify program behavior.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News