strace

13 commands

13 shown

Trace a new process Run a command under strace and save output to file strace -o trace.log ls /tmp #strace#linux#debug Attach to running process Trace syscalls of an already-running process by PID strace -p $(pgrep nginx | head -1) -o /tmp/nginx.trace #strace#linux#debug Trace only specific syscalls Filter to file-related syscalls only strace -e trace=openat,read,write curl https://example.com #strace#linux#debug Count syscall statistics Summary table of syscall counts and time spent strace -c -e trace=all python3 app.py #strace#linux#debug#performance Follow child processes Trace syscalls in all forked children (-f) strace -f -e trace=process nginx -t #strace#linux#debug Show timestamps -tt adds absolute time; -T shows time spent in each call strace -tt -T curl https://example.com 2>&1 | head -40 #strace#linux#debug#performance Trace file access Find files the process tries to open but cannot find strace -e trace=openat -e trace=file myapp 2>&1 | grep 'ENOENT' #strace#linux#debug Trace network syscalls Capture all network-related syscalls strace -e trace=network,socket curl https://example.com 2>&1 | grep -v '^---' #strace#linux#debug#network Syscall count summary Aggregate syscall counts/time across forks, sorted by time; pinpoints the costly call strace -c -f -S time -p <pid> #strace#performance#debug#troubleshooting Decode fds with timing Show paths/sockets behind fds plus per-call duration and timestamps for file ops strace -yy -T -tt -e trace=%file -p <pid> #strace#debug#disk#troubleshooting Stack trace per syscall Print user stack on each openat to find which code path opens a file; needs debug symbols strace -k -e trace=openat -f -p <pid> #strace#debug#troubleshooting#disk Syscall fault injection Force the 3rd openat to fail with ENOENT to test error handling; chaos testing without code strace -f -e inject=openat:error=ENOENT:when=3 -p <pid> #strace#debug#troubleshooting#ci Trace signals delivered Show only signals (SIGTERM/SIGCHLD) and skip syscalls; debug mysterious kills. note: ltrace for libcalls strace -f -e signal=all -e trace=none -p <pid> #strace#debug#troubleshooting#kernel
no commands match