Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
1  
What's the output of ldd /usr/bin/ssh? It might depend on a library (.so file) that doesn't exist. –  mrb Sep 28 '12 at 14:32
3  
So file says it uses shared libs, and ldd doesn't... something's screwed up. Try readelf -l /usr/bin/ssh and look for a "Requesting interpreter" line (or error). –  Mat Sep 28 '12 at 14:48
1  
@mrb Same comment about ldd actually running the program to you, too. Its important that people know this, less they try ldd when analyzing an untrusted binary. –  derobert Sep 28 '12 at 14:53
1  
ldd doesn't call _start/main as normal when called on a normal dynamically-linked executable, but an executable can be crafted to run arbitrary code on being examined with some versions of ldd. –  Random832 Sep 28 '12 at 16:12
4  
@strangefishinthetown You might try removing /etc/ld.so.cache and checking the contents of /etc/ld.so.conf and /etc/ld.so.conf.d. Run ldconfig to rebuild the cache afterwards. –  Jim Paris Sep 28 '12 at 17:36
show 14 more comments

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.