how to add repository in Ubuntu

Summary:  In this post i explained how to add repository in Ubuntu from command line.
The Basics:
Ubuntu package management uses apt. In Ubuntu file /etc/apt/sources.list apt stores software channels or list of repositories.

Depending on the situation we can add, remove or disable repositories from command line by editing this file.

We have to backup the original file in-order to restore if any thing goes wrong.

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

Now Open the file sources.list

vim /etc/apt/sources.list

let say we want to add the following repostiries

Add these line at the last of the file.

#Added Universe repositories
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe

save and exit with option wq!

Now we have to update the OS in-order to update the repositories to its latest versions.

apt-get update

All done smoothly.

Have a good day.

Leave a Reply

Your email address will not be published. Required fields are marked *