Bash

strace

Syntax#

  • strace -c[df] [-In] [-bexecve] [-eexpr]… [-Ooverhead] [-Ssortby] -ppid… / [-D] [-Evar[=val]]… [-uusername] command [args]

How to observe the system calls of a program

For an executable file or command exec, running this will list all system calls:

$ ptrace exec

To display specific system calls use -e option:

$ strace -e open exec

To save the output to a file use the -o option:

$ strace -o output exec

To find the system calls an active program uses, use the -p option while specifying the pid [how to get pid] :

$ sudo strace -p 1115

To generate a statistics report of all the system calls used, use option -c:

$ strace -c exec 

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow