What are strace and ltrace used for?
Answer
strace traces system calls made by a process — every interaction with the kernel (file opens, network ops, memory allocation, signals). Usage: strace -p PID attaches to a running process, or strace ./myapp arg traces from launch. strace -e trace=file filters to only file-related syscalls. strace -o output.txt ./myapp saves trace to a file. It is the go-to tool for diagnosing mysterious failures: "permission denied" (check which file it tries to open), "connection refused" (see the connect() call), or hangs (see what it's blocked on). ltrace similarly traces library function calls (libc functions like malloc, printf, strcpy). Both tools add significant overhead and are only for debugging, never production.
Previous
What does lsof do and when is it useful?
Next
How do netstat and ss show network connections?