[GTALUG] How much do you know about how linux executes binaries?

Sergio Durigan Junior sergiodj at sergiodj.net
Wed Dec 11 15:28:30 EST 2019


On Wednesday, December 11 2019, Lennart Sorensen via talk wrote:

> Someone at work just made a slight mistake:
>
> root at ECA:~# cd /var
> root at ECA:/var# mv core.* /*   [clearly that trailing * was not meant to be there]
> [bunch of errors about target already existing]
> root at ECA:/var# ls
> -bash: /bin/ls: No such file or directory
> root at ECA:/var#
>
> So what do you do now?

Everything that could be moved was moved under /var, because it's the
last directory (alphabetically) on /.

You will have to invoke the dynamic loader by hand in this case, because
it has been moved as well.  On Debian GNU/Linux 64-bit, you can find it
at /var/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2.  You will also have
to set LD_LIBRARY_PATH accordingly, otherwise the binary to be executed
will not be able to find its required libraries (mainly libc.so, in this
case):

# export LD_LIBRARY_PATH=/var/lib/x86_64-linux-gnu
# /var/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /var/bin/ls

You can now invoke 'mv' and move the contents back to /.

Cheers,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


More information about the talk mailing list