So, basically I was messing up with minix and qemu and I messed up too much.

me@meplepl ~ $ which
bash: /usr/bin/which: cannot execute binary file: Exec format error

me@meplepl ~ $ file  /bin/which
/bin/which: Minix-386 executable

I have the same problem with awk and somehow ssh. It turns out I somehow replaced my binaries with those from minix? Is there easy fix or I have to go back to my previous backup?

  • 2
    So you replaced some Linux executables with Minix ones? Reinstall them. What distribution? – schaiba Dec 3 '15 at 19:31

If your package manager is in a working state, you can force reinstallation of the packages containing the binaries you overwrote. Depending on your distro:

  • apt-get --reinstall install *package-name*

  • rpm -iv --replacepkgs *package-name*

  • yum reinstall *package-name*

  • emerge *package-name*

  • pacman -S *package-name*

If that doesn't work, you say you have backups so I would just restore /bin and /usr/bin from the backup.

A helpful way to avoid doing this in the future is the age old advice "don't use the root account when you don't need to". Once qemu is installed you can run it as your user. The benefit is that your user cannot overwrite /usr/bin on the host, so you can't mess up your system.

  • Thank you. This method with package manager didn't work, however replacing only /usr/bin and /bin with previous backup worked. I can only say that useful command is: dpkg -S path to binary. It gives you package name of the program. Thanks for the solution! – carpenter Dec 3 '15 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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