DEV Community

Cover image for Can Linux `~ $ which` be improved?
oOosys
oOosys

Posted on

Can Linux `~ $ which` be improved?

Here my attempt to arrive at a tool able to report the actual executable which can be deep buried under symbolic links and script files:
WhichELF?

~ $ whichELF? which
    which
    -> /usr/bin/which
        ->  symbolic link to /etc/alternatives/which
            ( fileSize = 23 bytes )
            ->  symbolic link to /usr/bin/which.debianutils
                ( fileSize = 26 bytes )
                ->  POSIX shell script, ASCII text executable
                    ( fileSize = 946 bytes )
#! /bin/sh
    /bin/sh
    -> /bin/sh
        ->  symbolic link to dash
            ( fileSize = 4 bytes )
            ->  ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=f7ab02fc1b8ff61b41647c1e16ec9d95ba5de9f0, for GNU/Linux 3.2.0, stripped
                ( fileSize = 125688 bytes )
                    -> LAST SCRIPT LINE (may list the actual used or further executable):
                        -> exit "$ALLRET"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)