How to solve E: unable to locate package error on Ubuntu desktop. The most common reason for this is that your /etc/apt/sources.list is missing or it is corrupted. You can run the following commands to add the four main repositories:
sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
Now update the system:
sudo apt-get update
sudo apt-get upgrade
Once you have executed the commands add security and update repositories using the following commands – the following set of commands are for Ubuntu 18.04 LTS. Similarly you can replace the version name and run the commands for different Ubuntu version:
sudo -- sh -c "echo 'deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse main restricted universe' >> /etc/apt/sources.list"
sudo -- sh -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic-updates multiverse main restricted universe' >> /etc/apt/sources.list"
sudo -- sh -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic-backports multiverse main restricted universe' >> /etc/apt/sources.list"
When the above commands are executed, the /etc/apt/sources.list should look as – use the command “cat /etc/apt/sources.list” to view the content:
deb http://archive.ubuntu.com/ubuntu bionic main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse main restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-updates multiverse main restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-backports multiverse main restricted universe
Now update the system:
sudo apt-get update
sudo apt-get upgrade
Some times you are “Unable to locate package” while installing packages with apt or apt-get commands. To fix these, open software-properties-gtk. Run the following command:
software-properties-gtk
Must for Update
- Open the “Ubuntu Software” tab.
- Ensure that the first 4 check boxes on this tab are enabled:
- The Updates tab is where you set when and how Ubuntu receives security updates.
- Make sure you select it and click on the Close button.
- When prompted click on the “Reload” button:
- The system will update cache
- Update the system and install packages
Once updated you are ready to install or update your system using the apt-get command or apt command:
sudo apt-get update
sudo apt-get upgrade