You are here: Home » NewsFeeds » Introduction to strace

Introduction to strace

There will come a time when you will find yourself asking “What the heck is that process doing?”. To uncover the mysteries behind the behaviour of a process, we have a tool called strace.
The program strace is very handy when you want to debug the execution of a program. It catches and states all the system calls performed called by a process. It will also catch and state any inter-process signals received by this process.
Let’s dive into some examples.
Trace the execution the simple straight-forward way to use it. The output might look something like:

execve(“/bin/ls”, [“ls”], [/* 32 vars */]) = 0brk(0)                                  = 0x1117000mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe7c5bc2000access(“/etc/”, R_OK)      = -1 ENOENT (No such file or directory)open(“/etc/”, O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=69243, …}) = 0mmap(NULL, 69243, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe7c5bb1000close(3)                                = 0open(“/lib64/”, O_RDONLY|O_CLOEXEC) = 3read(3, “177ELF2113>1240d”…, 832) = 832fstat(3, {st_mode=S_IFREG|0755, st_size=142136, …}) = 0mmap(NULL, 2242712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =


Original article