How to Edit /etc/apt/sources.list in Ubuntu

In Ubuntu the /etc/apt/source.list file is a configuration file for Advance Packaging Tool (APT). This file saves all URLs for remote repositories from where software packages and applications are installed.
When you install any software using the apt install or apt-get install then the apt tool looks inside the file /etc/apt/sources.list for the available remote repository links. And then it searches for the required software from that available remote repository and starts the download and installs it.

You can add, delete and modify the remote repositories directly from the /etc/apt/sources.list file. Just follow the below methods to edit /etc/apt/sources.list file in your Ubuntu system.

Edit /etc/apt/sources.list File

First backup the /etc/apt/sources.list using the below command. Open the terminal app (ctrl+alt+t) and run

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

You can edit that file using GUI and command-line methods.

Also Read:  W3m Command line Web Browser

Edit /etc/apt/sources.list GUI Method:

In terminal run this command. It will open the /etc/apt/sources.list file in gedit text editor.

sudo gedit /etc/apt/sources.list

source list file

Here you can add, edit and delete the remote repositories details.

Edit /etc/apt/sources.list CLI Method:

You can edit the file using the command line editor nano using below command in terminal app.

sudo nano /etc/apt/sources.list

source list nano

This will open that file nano cli editor. make the necessary changes and save it. That’s all.

 

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



This Post Has 2 Comments

  1. samuel

    please i need a guide to the necessary changes i need to make after the command:
    sudo nano /etc/apt/sources.list

    thank you in anticipation

    1. Manikandan

      You can easily edit using GUI method.

      For Nano Editor:
      At the bottom you will get some basic command shortcuts. The symbol (^) represents the Ctrl key.
      you can start typing and editing the text immediately after opening the file.
      For complete usage guide please check here. https://www.nano-editor.org/docs.php

Leave a Reply to Manikandan Cancel reply