Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
well.. you could use sed to replace the server with another with a "s/oldserver/newserver/" –  Karthik T Dec 10 '12 at 8:49
add comment

2 Answers

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.

share|improve this answer
    
+1 for sed, and then use something like capistrano to run it on all your servers. –  Till Sep 28 '13 at 23:28
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.