3

I accidentally deleted all the files in the folder /etc/apt which contains sources.list.

Now I am not able to install any software via terminal; I get this error every time:

Package has no installation candidate

How can I fix this? Thank you in advance :-)

1
  • This is the seed of an answer that, if I am on the right track, I hope someone will test and expand in the answer section: see How can I restore configuration files. Since you can't use APT, you'll have to download the packages listed by dpkg -S /etc/apt and install them using dpkg -i. You may need some help from How can I restore the default repositories and I'm not sure this will work.
    – Zanna
    Jun 28, 2018 at 20:28

1 Answer 1

2

You can create sources.list in /etc/apt directory.

sudo touch /etc/apt/sources.list

Open file with nano.

sudo nano /etc/apt/sources.list

Copy following content in file.

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#


###### Ubuntu Main Repos
deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse 

###### Ubuntu Update Repos
deb http://in.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse 
deb http://in.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse 

Save it and You will be able to run

sudo apt update

and install any packages.

7
  • while copying the content it says "Read only" ..... it's not saving the changes.
    – shiv
    Jun 28, 2018 at 18:56
  • Use sudo with command
    – KK Patel
    Jun 28, 2018 at 19:20
  • yes sir i used. it's get copied successfully. but after running " sudo apt update" it shows this W: GPG error: in.archive.ubuntu.com/ubuntu bionic-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'in.archive.ubuntu.com/ubuntu bionic-updates InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
    – shiv
    Jun 28, 2018 at 19:29
  • sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32. Run and try again. It should work.
    – KK Patel
    Jun 28, 2018 at 19:32
  • its shows :- Executing: /tmp/apt-key-gpghome.icm5OLsLPH/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 gpg: key 3B4FE6ACC0B21F32: 18 signatures not checked due to missing keys gpg: key 3B4FE6ACC0B21F32: public key "Ubuntu Archive Automatic Signing Key (2012) <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 W: Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory) W: Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory)
    – shiv
    Jun 28, 2018 at 19:36

You must log in to answer this question.

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