4

I wanted to reinstall the APT Tool, so I uninstalled it, and then I realized that it probably would've been better if I just deleted the /etc/apt directory. Is there any way that I can fix my screw-up?

My Ubuntu version is 18.04.2 LTS and the output of ls /etc/apt was

root@user-OptiPlex-755:~# ls /etc/apt 
ls: cannot access '/etc/apt': No such file or directory

UPDATE: I have re-installed apt, however, this is my output:

root@user-OptiPlex-755:~# sudo apt install --reinstall apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package update-manager is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
ubuntu-release-upgrader-core update-manager-core

Package update-notifier-common is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

Package update-notifier is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
update-notifier-common

Package apt-utils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
apt

Package ubuntu-release-upgrader-gtk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'apt-utils' has no installation candidate
E: Unable to locate package ubuntu-minimal
E: Package 'ubuntu-release-upgrader-gtk' has no installation candidate
E: Unable to locate package ubuntu-desktop
E: Package 'update-manager' has no installation candidate
E: Package 'update-notifier' has no installation candidate
E: Package 'update-notifier-common' has no installation candidate`
11

2 Answers 2

7

If you remove APT using sudo apt remove apt, following packages are affected in a standard installation (at least in bionic (18.04)):

apt apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common

To reinstall APT:

  • Download the .deb file of APT.

    wget http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.8_amd64.deb
    
  • Install using dpkg.

    sudo dpkg -i apt_1.6.8_amd64.deb
    
  • Since you deleted /etc/apt as well, download the zip for bionic from GitHub, extract it and copy the apt folder using:

    sudo cp -r ~/Downloads/Bionic/apt /etc/
    

    And run update:

    sudo apt update
    
  • Install removed packages again.

    sudo apt install apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common
    

Also, never try to mess up system files/packages like Python, APT, etc which are very essential for the OS. They may cause your system to break. If you need to reinstall a package, run:

sudo apt install --reinstall <package>
8
  • Nice answer! Deleted my draft with similar ideas :) But real /etc/apt/sources.list is needed too.
    – N0rbert
    Feb 28, 2019 at 20:44
  • @N0rbert Oops!! Sorry for that. I do believe that OP uninstalled just apt and haven't messed /etc/apt yet. And mere uninstalling apt doesn't affect that folder. So, I think sources.list should be fine.
    – Kulfy
    Feb 28, 2019 at 20:51
  • It seems that we need some clarification from OP.
    – N0rbert
    Feb 28, 2019 at 20:57
  • @N0rbert Yeah may be. I'll try to update my answer if OP adds some additional information. Meanwhile I strongly believe this answer addresses what OP has mentioned in the question as of now. :)
    – Kulfy
    Feb 28, 2019 at 20:59
  • I managed to reinstall apt (Thanks!), however, I wasn't able to install any of the removed packages. Should I post output? Feb 28, 2019 at 21:20
1

UPDATE: I do have an Ubuntu server right next to me, so I merged its /etc/apt with this Ubuntu, and the problem was solved. Thank you for all your help, and I'm pretty sure the core of my second problem was that I was missing the /etc/apt/sources.list file. Once I copied these files over, I was able to install the removed packages. Once again, thank you for all your help!

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .