deleted all the files in usr/bin typing in rm -rf *
Solution 1
Since you just installed today, do the installation again. While you can recover from this, it'll be a lot more work than redoing the installation.
To recover from the deletion of /usr/bin
, you would need to reinstall all the packages that have files in that directory. You can use this command to list the affected packages:
cd /var/lib/dpkg/info
grep -l '^/usr/bin/' *.list | sed 's/\.list$//'
You'll then need to find some way of downloading the packages without relying on any of the deleted programs. Since you've deleted dpkg
, the low-level package installation utility, you'll need to obtain it from somewhere first. Grab it from some other machine running the same release Ubuntu, or download the dpkg
package on another machine and extract the programs from it. You'll need not just /usr/bin/dpkg
but also all the other programs in that package, including update-alternatives
and all the programs named /usr/bin/dpkg-*
. Again, copying might be tricky with so many programs deleted, so you may need to reboot to a rescue CD/USB to do it.
Once you have the dpkg
suite, download at least the dpkg
and apt
package somehow, perhaps on another machine or in a still-running web browser.
Then install apt
manually with the command
dpkg -i /path/to/apt_0.8.16~exp12ubuntu10.2.deb
If you get errors about missing commands, reinstall the corresponding packages first. Then reinstall all the affected packages:
apt-get --reinstall install $(grep -l '^/usr/bin/' *.list | sed 's/\.list$//')
Again, in your situation, just do a complete reinstallation.
Solution 2
/usr/bin/
contains most of the programs that are installed on your system.
Just installing Ubuntu again would be the easiest and fastest way to get a working system again.
user1455116
Updated on September 18, 2022Comments
-
user1455116 over 1 year
I'm new to linux and installed Ubuntu 12.04 today. I accidentally deleted everything in
/usr/bin
typing in the commandrm -rf *
.I don't know what is mounting and would like to learn but at this point I think the only way left for me is to re install everything. Please let me know the ways to re install everything now. It would be of great help to me.
-
nanofarad over 11 years
/usr/bin
contains some programs' executables. Not all programs are there, and their data files are not there either. -
user1455116 over 11 years@Florian Diesch Hi i would definitely do that. Now i have windows 7 in one partition and ubuntu in another (80gb). Can i reinstall in the same 80gb space?
-
user1455116 over 11 yearsi would definitely go for a re installation. But can i reinstall it on the same 80gb memory i used install the current one?
-
h3. over 11 years@user1455116 Yes, tell the installer to use the existing partition and to erase its content.
-
phoibos over 11 yearsHm,
which dpkg
says dpkg is in/usr/bin/dpkg
, so that won't be available... -
user1455116 over 11 years@Gilles how do i do that? i already tried restarting with the cd in the drive and splits my current windows memory into two, and does not show the 80gb part :(
-
InColorado over 11 years@user1455116 That's the way to go.
-
Christopher B. Adkins over 11 years@user1455116 Yes. just be careful to select the right partition when installing.
-
user1455116 over 11 years@ngel Araya im not having any option saying wipe the current ubuntu and reinstall while i start from the CD, it is creating another partition and a third OS :(
-
h3. over 11 years@phoibos Right, thanks, so recovery is likely to require booting to a rescue CD.
-
h3. over 11 years@user1455116 I'm not familiar with the 12.04 installer. Tell it to use custom partitioning.
-
Christopher B. Adkins over 11 years@ObsessiveFOSS: Of course it is possible the rescue the system without reinstalling. It would only take much longer and require some advanced knowledge about system internals.