Bash/Get ancestry
From Attie's Wiki
(Difference between revisions)
m |
m (Attie moved page Get ancestry to Bash/Get ancestry) |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
This simple one-liner will output your full ancestry, starting from you and going up to init. | This simple one-liner will output your full ancestry, starting from you and going up to init. | ||
− | If you don't have permission to read a | + | If you don't have permission to read a symlink, a '?' will be shown. |
<source lang="bash"> | <source lang="bash"> | ||
PID=$$; until [ $PID -eq 0 ]; do BIN=$(readlink /proc/$PID/exe || echo "?"); echo "$PID: $BIN"; PID=$(ps -ef | awk "\$2==$PID {print \$3}"); done | PID=$$; until [ $PID -eq 0 ]; do BIN=$(readlink /proc/$PID/exe || echo "?"); echo "$PID: $BIN"; PID=$(ps -ef | awk "\$2==$PID {print \$3}"); done | ||
</source> | </source> |
Latest revision as of 17:05, 14 February 2013
This simple one-liner will output your full ancestry, starting from you and going up to init. If you don't have permission to read a symlink, a '?' will be shown.
PID=$$; until [ $PID -eq 0 ]; do BIN=$(readlink /proc/$PID/exe || echo "?"); echo "$PID: $BIN"; PID=$(ps -ef | awk "\$2==$PID {print \$3}"); done