Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

An android project has its /bin directory and what I wanted to do is to deleted this. What I actually mean is delete /path/to/android-project/bin not the /bin directory.

So I executed this command,

path/to/android-project$ sudo rm -rf /bin

Now, the entire /bin directory is deleted. I wanted to try restoring it in by using terminal but I cant launch the terminal since there are files in /bin related to terminal that have been deleted (my guess).

Are there any ways to restore /bin directory? I'm looking into upgrading ubuntu.

share|improve this question
I'm sure you didn't need root access to remove the directory you intended to remove, unless perhaps a build script created files owned by root. This is one of the reasons you should NEVER carelessly use sudo! Always think twice before using it. Unfortunately, this is a pretty common scenario among new users: "Permission denied? I know, I know. I'll use sudo! Whoops, now I've accidentally deleted <insert essential system directory here>." – nyuszika7h Dec 14 '14 at 11:16
up vote 5 down vote accepted

/bin contains some of the most basic files on your system, and it won't be able to do much without it (booting will not work, same for installing packages). Your best bet is to boot a live cd of the same Ubuntu version as what you are using, mount your exisitng root partition and rsync its /bin over to that partition.

For a full cleanup afterwards, reinstall the affected packages. To find which packages to reinstall, use this command:

find /bin -type f | xargs dpkg -S | sed -e 's/:.*//' | sort -u

And to actually reinstall them:

sudo apt-get install --reinstall $(find /bin -type f | xargs dpkg -S | sed -e 's/:.*//' | sort -u)
share|improve this answer

In general, every file or folder can be restored, only if you have backup of that practicular file or folder, be carefull when working in terminal, some processes are not recoverable!!! When you write / at first place, no matter where ever you are now, its gonna search for root!!! ./ stands for the current directory, and ../ for the parent (one level up) directory. I am not gonna suggest you to use any bin directory copy beacause i am not sure it could help, but I can tell you to install ubuntu on a new partition, backup your files in that way, if you are not familiar with terminal.

share|improve this answer

Your Answer


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.