When I want to change the mirror I am using for updates, I can open the Software Centre, and go to Edit->Software Sources, and from there select another server.

This then goes through my /etc/apt/sources.list file, and replaces all the instances of the old mirror URL, with the new mirror URL.

If, however, I want to do this on the command line (perhaps I'm not running X, or I'm connecting over ssh), I have to go through the /etc/apt/sources.list file myself and change each instance.

This isn't the hardest thing to do, and of course I can do a search and replace, but it is a lot more work than just clicking the name of the server I want, plus it requires me to know a bit about the syntax of the sources.list file, and make sure I don't make an error while editing it.

Is there a command line program which can perform the same task as the Software Centre, and change my update mirror, without me having to edit this file?

  • well.. you could use sed to replace the server with another with a "s/oldserver/newserver/"
    – Karthik T
    Dec 10, 2012 at 8:49

2 Answers 2


There is no command line GUI program like Software Center that can change in sources.list

You need to look into replacement via sed or adding to end of sources.list via cat

There are multiple questions here that helps with that.

Of course you can also edit manually via a text editor like nano.

nano has search and replace functions as well.

  • +1 for sed, and then use something like capistrano to run it on all your servers.
    – Till
    Sep 28, 2013 at 23:28

Just edit the /etc/apt/sources.list using your favorite text editor for e.g.

sudo emacs /etc/apt/sources.list

Since you have other repos listed already in the file the syntax is fairly clear. You will obviously need to know the address of the repo you are adding.

You must log in to answer this question.

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