1

So I was trying to install some packages, but they were sort of broken so an answer recommended that I use "apt-get remove" to remove the corrupted versions and re-install them. While doing that I got a warning that said "this could be harmful" then I thought meh and wrote "Yes, do as I say!".

Next thing I know, most of my windows were closing and icons disappearing so I had to forcefully close the terminal. I tried opening a new one to re-install everything but it wouldn't open, so I restarted my laptop.

When Ubuntu opened again, it showed me the black and white terminal (I believe it is called tty) and when I tried to use apt-get to maybe fix things and install everything I removed (and perhaps a desktop), it said the "apt-get" package was not found.

So yeah, I kind of messed up my OS but I want to know if there's a way to fix this without reinstalling Ubuntu because there's a lot of software that I would rather not go through installing them again..

  • See your bash history to find out what commands did you run, then install the missing packages that was removed.You might need to install ubuntu-desktop package too. – Parsa Mousavi Jun 26 '20 at 09:34
  • Is there a way I can do that without apt-get command? Because this package was uninstalled too.. – Diaa Eldin Malek Jun 26 '20 at 09:35
  • Which ubuntu version do you use? – Parsa Mousavi Jun 26 '20 at 09:36
  • @ParsaMousavi 18.04 – Diaa Eldin Malek Jun 26 '20 at 09:38
  • So run wget http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.1_amd64.deb ; sudo dpkg -i apt_1.6.1_amd64.deb – Parsa Mousavi Jun 26 '20 at 09:41
  • @ParsaMousavi Ok thank you I will try this. Also, I'm using dual boot. Is using Windows to manually download packages and place them into Ubuntu directories a smart option? – Diaa Eldin Malek Jun 26 '20 at 09:44
  • 1
    It would probably help if we knew more of what you deleted (I can't imagine what you removed that would cause https://packages.ubuntu.com/bionic/apt to be removed..), but wget to grab & then dpkg to install is where I'd go until you can use higher level tools.. – guiverc Jun 26 '20 at 09:45
  • @DiaaEldinMalek If you have access to the ubuntu partition in your windows , then yes. – Parsa Mousavi Jun 26 '20 at 09:53
  • @ParsaMousavi The commands worked, I did apt-get upgrade & check because they seemed suitable for my situation. How do I know which other vital packages are missing (other than waiting for errors to pop up)? – Diaa Eldin Malek Jun 26 '20 at 10:00
  • @guiverc The package I was removing earlier was libstdc++ (apt-get purge). I knew it was a necessary package but I didn't realize it would wreck the OS like that. I guess it's because I used purge instead of simply remove? Not sure – Diaa Eldin Malek Jun 26 '20 at 10:04
  • For informational/learning purposes, look at my prior provided link on the apt package; it lists the depends packages apt requires.. ie. when you removed the gnu C++ standard library you caused everything that was compiled in C++ (requiring) it to be removed... which is why you shouldn't '-y' or "yes" without at least scanning packages looking for consequences.. (unless it's for learning sake & you have good backups). It didn't wreck the OS, you just lost access to any tool that required it (dpkg & many tools are written in C [not C++] so weren't impacted..), ie. learn... – guiverc Jun 26 '20 at 10:52
  • @guiverc I'm glad a new installation is not necessary if I re-add the missing packages. Thanks for the tip! – Diaa Eldin Malek Jun 26 '20 at 11:41
  • @ParsaMousavi And thank you so much for your help – Diaa Eldin Malek Jun 26 '20 at 11:41

0 Answers0