Flags, examples, and output format reference.
| Flag | Argument | Description | |
|---|---|---|---|
| ๐จ | -c | Force-enable ANSI color output. Auto-detected when stdout is a tty; NO_COLOR=1 disables it. | |
| ๐ | -d | Print working directory of each process (via /proc/<pid>/cwd). Shown before the command, separated by %. | |
| ๐ฟ | -e | Print full environment of each process. One variable per line, indented under the exec line. | |
| โฌ | -f | Flat output โ suppress indentation. Useful when piping to grep or awk. | |
| ๐ | -l | Print the full resolved executable path (via /proc/<pid>/exe) instead of argv[0]. | |
| ๐ | -o | FILE | Append output to FILE instead of stdout. Colors are disabled for file output unless -c is also set. |
| ๐ฏ | -p | PID[,PID,...] | Only show exec()s in the subtree(s) of the given PID(s). Accepts a comma-separated list or can be specified multiple times. |
| ๐คซ | -q | Suppress arguments โ show only the executable name (argv[0]). | |
| ๐ | -Q | Suppress error messages (e.g. "process vanished before notification"). Useful for long-running background use. | |
| โฑ๏ธ | -t | Show exit status and wall-clock runtime. Adds + to exec lines and prints a - exit line for each process. | |
| ๐ค | -u | Print owning user of each process as <username> before the command. |
Each exec event produces one line. With -t, a matching exit line follows when the process terminates.
-f)
-t
-t, on process exit
-u
% โ only with -d
-l
-q)
The simplest invocation โ no flags, no command. Shows every exec() on the machine with process tree indentation.
$ sudo proc-trace-exec 1100 sshd 1101 bash 1150 git status 1151 git-status 1152 vim README.md
Run a command directly and trace its entire subtree. -t adds exec/exit markers and wall-clock timing.
$ sudo proc-trace-exec -t sh -c 'find /etc -name "*.conf" | head -3' 32741+ sh -c 'find /etc -name "*.conf" | head -3' 32742+ find /etc -name '*.conf' 32743+ head -3 32743- head exited status=0 time=0.001s 32742- find exited status=141 time=0.003s 32741- sh exited status=0 time=0.006s
Comma-separate PIDs from pgrep to watch a whole group of processes at once.
$ sudo proc-trace-exec -p $(pgrep nginx | paste -sd,) -u -t
Combine flags for maximum context: user, working directory, and fully resolved executable path.
$ sudo proc-trace-exec -u -d -l -t sh -c 'ls /tmp' 41000+ <root> /root % /usr/bin/dash -c 'ls /tmp' 41001+ <root> /root % /usr/bin/ls /tmp 41001- ls exited status=0 time=0.001s 41000- dash exited status=0 time=0.002s
Use -f to remove indentation, making it safe to pipe to grep, awk, or tee.
$ sudo proc-trace-exec -Qf | grep python
Run in the background, suppressing all error noise, and write to a log file for later analysis.
$ sudo proc-trace-exec -Qto /var/log/execs.log & [1] 9981
Grant CAP_NET_ADMIN to the binary so normal users can run it without sudo.
$ sudo setcap cap_net_admin+ep ./proc-trace-exec $ ./proc-trace-exec -t make # runs as your user, no sudo needed