How to re-create the repositories in /etc/apt folder in Ubuntu 18.04

8,097

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.

Share:
8,097

Related videos on Youtube

shiv
Author by

shiv

i am a student of open source technology , specially intrested in linux.

Updated on September 18, 2022

Comments

  • shiv
    shiv over 1 year

    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 :-)

    • Zanna
      Zanna almost 6 years
      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.
  • shiv
    shiv almost 6 years
    while copying the content it says "Read only" ..... it's not saving the changes.
  • Darryl Williams
    Darryl Williams almost 6 years
    Use sudo with command
  • shiv
    shiv almost 6 years
    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.
  • Darryl Williams
    Darryl Williams almost 6 years
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32. Run and try again. It should work.
  • shiv
    shiv almost 6 years
    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)
  • Darryl Williams
    Darryl Williams almost 6 years
    sudo mkdir /etc/apt/apt.conf.d/
  • Zanna
    Zanna almost 6 years
    the problem is that sources.list is not the only file in /etc/apt/. There are various other important files and directories there and APT probably will not work without them :(