execsnoop(8)
β¨ execsnoop(8) β¨
π NAME π
execsnoop is a tracer for new processes, using exec() syscalls. It runs on Linux eBPF/bcc. β¨
π§ SYNOPSIS π§
execsnoop [-h] [-T] [-t] [-x] [--cgroupmap CGROUPMAP] [--mntnsmap MAPPATH] [-u USER] [-q] [-n NAME] [-l LINE] [-U] [--max-args MAX_ARGS]
π¦ DESCRIPTION π¦
okay so execsnoop traces new processes and shows you the filename being executed plus the argument list. iykyk π«Ά
It works by tracing the execve() system call, which is the most common exec() variant. This catches new processes that follow the fork->exec sequence, and processes that re-exec() themselves. Some apps will fork() without exec()ing, like worker processes, and those won't show up in the execsnoop output π
It works by tracing the kernel sys_execve() function using dynamic tracing, so it'll need updating to match any changes to that function. bestie, keep that in mind π
Since this uses BPF, only the root user can use this tool. No exceptions, no vibes-based workarounds π₯
π REQUIREMENTS π
You'll need CONFIG_BPF and bcc. β¨
π OPTIONS π
-hβ Prints the usage message. Your lifeline when you forget the flags π-Tβ Adds a time column inHH:MM:SSformat β°-Uβ Adds the UID column π-tβ Adds a timestamp column β¨-u USERβ Filters by UID or username π-xβ Also includes failedexec()s, the ones that didn't go through π-qβ Wraps arguments in "quotemarks" and escapes any quotemarks inside them with a backslash. This is the move for tracing empty arguments or arguments with whitespace in them π-n NAMEβ Only prints command lines matching this name, using a regex π-l LINEβ Only prints commands where an argument contains this line, using a regex π§΅--max-args MAXARGSβ The max number of arguments parsed and displayed. Defaults to20πΈ--cgroupmap MAPPATHβ Traces only the cgroups in this BPF map. It's filtered in-kernel, so it's lowkey efficient π--mntnsmap MAPPATHβ Traces only the mount namespaces in this BPF map. Also filtered in-kernel π§-P PPIDβ Traces only this parent PID π¦
π EXAMPLES π
Here are the vibes, bestie π
- Trace all
exec()syscalls:# execsnoop - Trace all
exec()syscalls and include timestamps:# execsnoop -t - Display the process UID:
# execsnoop -U - Trace only UID
1000:# execsnoop -u 1000 - Trace only processes launched by root and display the UID column:
# execsnoop -Uu root - Include failed
exec()s:# execsnoop -x - Put quotemarks around arguments:
# execsnoop -q - Only trace
exec()s where the filename contains "mount":# execsnoop -n mount - Only trace
exec()s where an argument's line contains "testpkg":# execsnoop -l testpkg - Trace a set of cgroups only (check
special_filtering.mdfrom the bcc sources for more details):# execsnoop --cgroupmap /sys/fs/bpf/test01
π FIELDS π
TIMEβ When theexec()returned, inHH:MM:SSformat β°TIME(s)β When theexec()returned, in seconds β³UIDβ The user ID πPCOMMβ The parent process or command name π―PIDβ The process ID πͺͺPPIDβ The parent process ID πRETβ The return value ofexec().0means success! Failures only show up when you use the-xoption πARGSβ The filename for theexec(), followed by up to 19 arguments. An ellipsis...shows up if the argument list is known to be truncated π«£
π₯ OVERHEAD π₯
This traces the kernel execve function and prints output for every event. The rate is usually expected to be low (< 1000/s), so the overhead should be negligible. But if your app is calling exec() at a high rate, test it and understand the overhead before you use this tool. Don't be the girl who tanks prod π
πΈ SOURCE πΈ
This is from bcc, found at:
https://github.com/iovisor/bcc
Also check the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool π
π OS π
Linux π§
π«§ STABILITY π«§
Unstable, still in development π§
π AUTHOR π
Brendan Gregg, Rocky Xing π©βπ»
π¦ SEE ALSO π¦
opensnoop(1) π
Bye bestie π«Ά This page is from USER COMMANDS, dated 2020-02-20, and it's all about execsnoop(8) πβ¨
π¦ where this page comes from
- alpine 3.24: bcc-doc 0.36.1-r1 Β· Apache-2.0
- nixpkgs unstable: bcc 0.37.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms