Debian – Command & binary exists but cannot be executed

aptcommanddebian

I transfered /etc/* files from one Linux server to another and now I have a strange error. Both are Debian Squeeze.

When I run a command, e.g. ssh, I get an error:

bash: /usr/bin/ssh: No such file or directory

It looks like the binary exists:

-rwxr-xr-x 1 root root 358756 Sep 21 14:30 /usr/bin/ssh

Bash also autocompletes the command when I type ss and press Tab. I tried reinstalling, purging etc but it didn't solve anything. There is probably something cached under /etc/ but I don't know what excatly.

Best Answer

I think Jim Paris's comment is right on the mark. You can get “no such file or directory” even if the specified file exists, if the dynamic loader for that file does not exist. A common case is trying to run a binary from a different architecture that the kernel supports but not the user-land system — typically a 32-bit binary on a 64-bit system that doesn't have 32-bit libraries installed. See Getting "Not found" message when running a 32-bit binary on a 64-bit system for a more detailed explanation of that case.

Here, it's possible that /usr/bin/ssh uses a library that is installed in a different place on the new system. Since you copied the dynamic linker's cache file /etc/ld.so.cache, the dynamic linker is looking for that library in a place where it doesn't exist. Run ldconfig to update the cache.

It's also possible that you'd enabled prelinking. If so, remove /etc/prelink.cache.

Related Question