How can I re install the APT Tool?
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`
Solution 1:
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>
Solution 2:
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!