wonderfly Blog

Random Tricks

Random Tricks

This documents of a list of tips and tricks I’ve found useful and tend to forget.

Trace all files access by a process

strace. strace has a -e (for expresssion) option that lets you select the things to trace and not trace. For example, to trace all files opened by a process, you could do -e open,openat. That would filter out all other syscalls. However, by default strace still traces signals which can be annoying. To turn that off, add -e signals=none.

$ sudo strace -e openat,open -e signals=none -p 13167
strace: Process 13167 attached
openat(AT_FDCWD, "/proc/13167/stat", O_RDONLY) = 49
openat(AT_FDCWD, "/proc/13167/schedstat", O_RDONLY) = 49
openat(AT_FDCWD, "/proc/13167/io", O_RDONLY) = 49
...