execsnoop(8)
β¨ execsnoop β the whole vibe π
okay so bestie, we're in the System Manager's Manual section, page execsnoop(8), and this little icon is about tracing exec() calls with arguments, using Linux ftrace. no cap. let's get into it π«Ά
πΈ NAME πΈ
execsnoop β trace process exec() with arguments. Uses Linux ftrace.
π SYNOPSIS π
execsnoop [-hrt] [-a argc] [-d secs] [name]
π¦ DESCRIPTION π¦
So execsnoop traces process execution, and it shows you the PID, the PPID, and the argument details if it possibly can. it's giving detective energy π
It traces exec() from the fork()->exec() sequence, which means β heads up β it won't catch new processes that only fork(). like, if you never exec, this tool literally cannot see you, sorry babe. β With the -r option though, it will also catch processes that re-exec. it makes a best-effort attempt to retrieve the program arguments and PPID; if those aren't available, 0 and "[?]" get printed respectively. there's also a limit on how many arguments get printed (default is 8), and you can bump that up with -a.
This implementation is designed to work on older kernel versions, and without kernel debuginfo. how does it do it?? it works by dynamic tracing an execve kernel function to read the arguments from the %si register. stub_execve() gets tried first, then do_execve(). The sched:sched_process_fork tracepoint is what handles the PPID. and now the serious part: tracing registers and kernel functions is an unstable technique, and this tool may not work for some kernels or platforms. π
This program is a workaround that should be improved in the future when other kernel capabilities are made available. If you need a more reliable tool right now, consider other tracing alternatives (eg, SystemTap). fr fr, this tool is really a proof of concept to see what ftrace can currently do.
And because it uses ftrace: only the root user can use this tool. sorry to the non-root girlies π
π§ REQUIREMENTS π§
FTRACEandKPROBECONFIG- the
sched:sched_process_forktracepoint - either the
stub_execve()ordo_execve()kernel function
You may already have these on recent kernels. And also: awk. yes bestie, awk is part of the squad, don't forget her π
π OPTIONS π
-aargc β Maximum number of arguments to show. The default is8, and the maximum allowed is16. Ifexecsnoopthinks it has truncated the argument list, an ellipsis"[...]"will be shown. π-dseconds β Duration to trace, in seconds. This also uses in-kernel buffering. β¨-hβ Print usage message.-rβ Include re-exec()s.-tβ Include timestamps in units of seconds. β±οΈ- name β Only show processes that match this name. Partials and regular expressions are allowed, as this is filtered in user space by
awk. so yes, you can be as picky as you want π
π EXAMPLES π
Trace all new processes and arguments (if possible):
# execsnoop
Trace all new process names containing the text "http":
# execsnoop http
β FIELDS β
- TIMEs β Time of the
exec(), in seconds. - PID β Process ID.
- PPID β Parent process ID, if this was able to be read. If it wasn't,
0is printed. - ARGS β Command line arguments, if these were able to be read. If they aren't able to be read,
"[?]"is printed (which would be due to a limitation in this tools implementation, since this is workaround for older kernels; if you need reliable argument tracing, use a different tracer). They will be truncated to the argc limit, and an ellipsis"[...]"may be printed ifexecsnoopis aware of the truncation. π
π₯ OVERHEAD π₯
This reads and processes exec() events in user space as they occur. Since the rate of exec() is expected to be low (< 500/s), the overhead is expected to be small or negligible. so like, chill. your CPU is fine π
π«Ά SOURCE π«Ά
This is from the perf-tools collection.
https://github.com/brendangregg/perf-tools
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool. it's got the receipts πβ¨
π OS π
Linux π§
π STABILITY π
Unstable β in development. she's still growing, be nice π
πΈ AUTHOR πΈ
Brendan Gregg
π¦ SEE ALSO π¦
and that's the whole thing bestie, you ate π
this page is execsnoop(8) from USER COMMANDS, dated 2014-07-07, and honestly? iconic. go trace something, but remember β root only, no cap πβ¨π
π¦ where this page comes from
- debian bookworm: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- debian trixie: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- ubuntu jammy: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu resolute: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- ubuntu stonking: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms