hexec(1)
β¨ hexec(1) β¨
okay bestie, buckle UP, because we're talking about hexec β it's the manual page for the process execution hooking tool, and it's genuinely so much fun π
πΈ NAME πΈ
hexec β a process execution hooking tool π
π¦ SYNOPSIS π¦
hexec <OPTIONS> [expr] [cmd] [args...]
π DESCRIPTION π
So like. hexec is a tool that hooks into process execution calls β we're talking the whole exec family of syscalls, all of them π
You get to define an expression, and that expression gets run against any hooked exec call. And here's the gag: that expression can also contain a replacement exec call. So you're not just watching, you're participating. main character energy fr fr β¨
β OPTIONS SUMMARY β
here's the little quick-look rundown of the options to hexec:
--help | -h Print a options/expr summary page
--version | -v Print hexec version
--log-out | -lo set output file for error and -print output
π OPTIONS π
-hβ prints the options/expr summary page. cute little cheatsheet moment π--helpβ same thing, prints the options/expr summary page π«Ά-loβ sets the output file for error output and for-printoutput. You might genuinely need this one, because if you're writing tostderrthat can cause malfunctions β some processes read fromstderrand expect a very specific, well-defined output. so yeah, redirect your vibes elsewhere π
π EXPRESSIONS π
The expression gets executed against all process execution calls. And the rule is: if the expression returns true, the original call gets skipped. periodt π
<expr> -and <expr><expr> -a <expr><expr> <expr>
Returns true if both expressions return true. And lowkey the efficient part: if the left one returns false, the right expression is never executed. no wasted work, we love to see it β
<expr> -or <expr><expr> -o <expr>
Returns true if one of both expressions returns true. Same shortcut energy: if the left returns true, the right expression is never executed β¨
-path <pattern>β returns true if the path of the executable matches<pattern>. And<pattern>is a bash compatible wild card pattern. slay π¦-ipath <pattern>β same as-path, but case insensitive. iykyk π-name <pattern>β returns true if the base name of the executable matches<pattern>.<pattern>is a bash compatible wild card pattern π-iname <pattern>β same as-name, but case insensitive πΈ-contains <str>β returns true if the path of the executable contains the string<str>π-icontains <str>β same as-contains, but case insensitive β¨-printβ prints all arguments to the called process. Returns always true π-exec <cmd> [args...] ;β executes<cmd>with[args...]as arguments. This expression must be terminated with a semicolon. You can use argument placeholders in<cmd>and[args...](see below). This expression always returns true.
β οΈ NOTE: please be aware that you may need to escape or quote the terminating semicolon so you don't confuse your shell. genuinely, do not forget this one π
-sh <script>β interprets<script>as a shell script by invoking/bin/shwith the arguments-c '<script>'. You can use argument placeholders inside<script>. Please note that-shonly expects a single argument and not a variable list of arguments (the way-execdoes). Using-shis the same as using-exec sh -c <script>π
π§ PLACEHOLDERS FOR -exec EXPRESSION π§
Every -exec expression can use placeholders in the argument list to grab info from the original exec call. Each placeholder starts with { and ends with }. And if you literally want a { in your argument list, use \{. The placeholders get replaced when the -exec expression is evaluated β¨
π Placeholder types π
{n}β gets replaced with the number of arguments in the original call.{<idx>}β gets replaced with the original argument at index<idx>. Example:{1}would give you the first argument. You can prepend<idx>with placeholder flags π{}β gets replaced with all arguments from the original call. Each argument is separated with a space. You can use placeholder flags π
NOTE: the executable name is also considered an argument. So a call like"echo test"will result in two arguments:"echo"and"test". don't forget this, it catches everyone π
π PLACEHOLDER FLAGS π
sβ every argument is inserted as a single argument instead of concatenating all the arguments together.
Consider the arguments 'a', 'b' and 'c'. Without s, -exec {} \; would result in -exec 'a b c' \;, which in many cases is not what you want. -exec {s} \; however would result in -exec 'a' 'b' 'c' \;. the difference is everything bestie π₯
qβ quote every single argument.eβ escape all non alpha-numeric characters. This flag is very useful when you're using a"sh -c <...>"in the-execexpression. lowkey essential β¨
πΈ Examples πΈ
-exec echo {} \; with the call 'a' 'b' 'c'
results in: 'echo' 'a b c'
-exec echo {q} \; with the call 'a' 'b' 'c'
results in: 'echo' 'a' 'b' 'c'
-exec sh -c 'echo {}; {}' \; with the call 'sh' '-c' 'gcc d.c >>
log.txt'
results in: 'sh' '-c' 'echo sh -c gcc d.c >> log.txt; sh -c gcc
d.c >> log.txt'
Please note that this will not do what you may expect, as the >>
is handled wrong in this case.
-exec sh -c 'echo {e}; {}' \; with the call 'sh' '-c' 'gcc d.c >>
log.txt'
results in: 'sh' '-c' 'echo sh \-c gcc\ d\.c\ \>\>\ log\.txt; sh
-c gcc d.c >> log.txt'
π CHANGES TO PROCESSES π
hexec will add some environment variables to the hooked processes. These are the ones (and this list may not be complete):
LD_PRELOADβhexecaddslibhexec-hook.soto the list of preloaded libraries πHEXEC_EXPR_SHMβ contains the name of the internal shared memory object π§HEXEC_LOG_FDβ contains the file descriptor for error and-printoutput π
β οΈ Please do never modify these environment variables. Also take care when you use these variables, because the name and content of the variables may change in the future. it's giving "handle with care" π
π₯ EXAMPLES π₯
hexec -name 'gcc' -exec ccache {s} \; make
Calls make, which will then call gcc several times. The executable name of each hooked process execution is tested against the file pattern "gcc" and "ccache {s}" is called each time a match is found. '{s}' will be replaced with the original (the hooked) call. In this example, a call to "gcc -o test.o test.c" would be replaced with "ccache gcc -o test.o test.c" ππ
π HOW IT WORKS π
TODO
...bestie they literally wrote TODO. iconic honestly π
π BUGS π
"I'm sure there are alot...it's still beta :)" β direct quote, and honestly? respect the honesty π«Ά
π AUTHOR π
hexec was written by Alexander Block http://blocksoftware.net/ π
If you wish to report a problem or make a suggestion then please email ablock@blocksoftware.net π§
hexec is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details π
aaaand that's the whole page bestie π
this was the hexec(1) manual, from November 2008, and yeah the page footer literally just says hexec(1) again because manpages love being extra. go forth and hook some exec calls, you absolute legend π¦β¨π
π¦ where this page comes from
- debian bookworm: hexec 0.2.1-4+b1
- debian trixie: hexec 0.2.1-4+b1
- ubuntu jammy: hexec 0.2.1-4
- ubuntu noble: hexec 0.2.1-4
- ubuntu resolute: hexec 0.2.1-4build1
- ubuntu stonking: hexec 0.2.1-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms