Why not use Software Sources command line parameters to do this automatically?
Add default repository
The tool that's accessed from Ubuntus administration menu is called software-sources-gtk. It can be given the name of the repository that should be enabled on the command line.
Example for installing partimage from universe repository
sudo software-sources-gtk -e universe sudo apt-get update sudo apt-get install partimage
That way, you can enable any of the four repositories main, universe, restricted, and multiverse.
Update for Ubuntu Hardy
The command changed lately from software-sources-gtk to software-properties-gtk.
Add third party repositories
Again, you shouldn't edit the /etc/apt/sources.list configuration directly, but instead you simply create a new file xyz.list in the /etc/apt/sources.list.d folder.
Example of adding repository for KeepassX
sudo add-apt-repository ppa:keepassx # For Hardy sudo echo "deb http://ppa.launchpad.net/keepassx/ubuntu/ hardy main # KeepassX" > /etc/apt/sources.list.d/keepassx.list sudo apt-get update
That way, it's much simpler to automate tasks like adding and removing third party repositories from shell scripts and keep your /etc/apt/sources.list file clean.