opensnoop.bt(8)
β¨ opensnoop.bt β the manual, but make it make sense β¨
okay so real talk, this is a page from the System Manager's Manual (the opensnoop.bt(8) one, iykyk) and it's literally about watching every single file your system tries to open. no cap, it's a whole vibe.
π NAME
opensnoop.bt β traces the open(), openat(), openat2() syscalls. and it does it with bpftrace/eBPF, which is the cool part. periodt.
π SYNOPSIS
opensnoop.bt -- [--depth=<N>] [--errname]
that's it bestie. that's the whole command. so clean.
πΈ DESCRIPTION
opensnoop traces the open(), openat(), openat2() syscall, and it shows you which processes are trying to open which files. which is genuinely so useful β like, you wanna know where an app's config files and log files actually live? boom, this tells you. you got an application that's failing, especially like right at startup and you're sitting there like "why π"? also this. it's giving detective energy ngl.
the way it works: it traces the open(), openat(), openat2() syscall tracepoint. that's the whole mechanism, nothing secret happening.
β οΈ since this uses BPF, only the root user can use this tool. no root, no snooping. fr fr.
π¦ OPTIONS
--depth=<N>β sets the max supported path depth you want to track. the default is35, so if your paths are getting real deep and dramatic, this is your girl π--errnameβ shows you the actual error message instead of the raw errno. so much friendlier honestly π₯Ί
π REQUIREMENTS
CONFIG_BPFbcc
that's the checklist. both of them. don't skip.
π₯ EXAMPLES
trace all the open(), openat(), openat2() syscalls β like, all of them:
# opensnoop.bt
ok and that # at the front? that's your root reminder. slay.
β FIELDS
this is what each column means, so you're not squinting at the output like ποΈπποΈ
PIDβ Process IDCOMMβ Process nameFDβ File descriptor, if it succeeded (or-1if it failed π)ERRβ Error number (go look at the system'serrno.hif you want the lore)PATHβ Open path
π OVERHEAD
so this thing traces the open tracepoint and prints output for each and every event. and because the rate of that is generally expected to be low (< 1000/s), the overhead is also expected to be like, negligible. tiny. barely a blip. π§
but β if you have an application that's calling a high rate of open()s, then test it and understand the overhead before you use it. that's an actual warning, not a suggestion π
π SOURCE
this is from bpftrace.
https://github.com/bpftrace/bpftrace
also! go look in the bpftrace distribution for a companion _examples.txt file β it's got example usage, output, and commentary for this tool. the whole package. π
one more thing: this is a bpftrace version of the bcc tool of the same name. the bcc tool may provide more options and customizations, so if you want the extra toppings, that's where they are.
https://github.com/iovisor/bcc
π OS
Linux. obviously. π
π STABILITY
Unstable β in development. she's still growing, be nice to her π«Ά
π AUTHORS
Brendan Gregg, Rong Tao <rongtao@cestc.cn>
π SEE ALSO
statsnoop.bt(8), execsnoop.bt(8)
go read those too, they're the friend group π β¨
and that's the whole page bestie β brought to you by USER COMMANDS, dated 2018-09-08, mwah π
π¦ where this page comes from
- alpine 3.24: bpftrace-tools-doc 0.26.1-r0 Β· Apache-2.0
- arch rolling: bpftrace 0.27.0-2 Β· Apache-2.0
- centos-stream 10: bpftrace 0.26.1-1.el10 Β· Apache-2.0
- centos-stream 9: bpftrace 0.26.1-1.el9 Β· ASL 2.0
- nixpkgs unstable: bpftrace 0.27.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms