Looking for a solution to switch repository from CD to mirror ones, without going to /etc/apt/sources.list and changing the content to Internet mirror list.
IMHO It is an absolute waste of time to do it just for one or two applications not included in the CD repo...

Similar as in yum, for instance

yum install --enablerepo=repository_name_here package_name

anything similar in Debian ?

  • 1
    Why not just keep the Internet mirror in the sources list all the time but after the CD ones. When downloading it should use the first available repo. See askubuntu.com/questions/135339/… – icarus Jan 8 '17 at 20:46

There are eight (8) CD:s for Debian Jessie, unless you happen to have them all, it's likely to be more than one or two applications that will not be found on the CD. Also, using a network mirror gives easier access to point releases, and you should probably get security updates from a network archive anyway.

Also, if you use a network mirror when installing, you don't need to edit sources.list to add it.

But, see also: How to add repository from shell in Debian?

  • have 3 DVD version, but there is no VNC server on them, But in general I'd like use CD repo, to save traffic... and even for security updates, every time editing /etc/apt/sources.list ... silly .... – user209328 Jan 8 '17 at 20:19

You can use sed command to disable/enable urls on your sources.list

to disable all urls :

sed -i '/debian.org/s/^/#/g' /etc/apt/sources.list

To enable all urls :

sed -i '/debian.org/s/^#//g' /etc/apt/sources.list

Change debian.org string with yours.


This script should do, it will back your current repo file and will create an alias, so you can enable disable repos by commands:

To enabel cd repo:


To enable net rep:



# backing up
if [ ! -f "/etc/apt/_back.sources.list_back" ]; then
cp /etc/apt/sources.list /etc/apt/_back.sources.list_back
fi && 
# creating repo file for net
cat <<"EOF" >> /etc/apt/sources.list_net
deb http://httpredir.debian.org/debian jessie main contrib
deb-src http://httpredir.debian.org/debian jessie main contrib
deb http://httpredir.debian.org/debian jessie-updates main contrib
deb-src http://httpredir.debian.org/debian jessie-updates main contrib
deb http://ftp.debian.org/debian/ jessie-updates main contrib
deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
# creating cd repo file
cp /etc/apt/sources.list cp /etc/apt/sources.list_cd

# enable cd-repo
cat <<"EOF">> /usr/local/bin/cd-repo-enable.sh
rm -fr /etc/apt/sources.list
cp /etc/apt/sources.list_cd /etc/apt/sources.list
apt-get update
chmod +x /usr/local/bin/cd-repo-enable.sh

# enabling net repo
cat <<"EOF">> /usr/local/bin/net-repo-enable.sh
rm -fr /etc/apt/sources.list
cp /etc/apt/sources.list_net /etc/apt/sources.list
apt-get update
chmod +x /usr/local/bin/net-repo-enable.sh 

# Removing old alias "net-repo-enable" if detected
sed -i 's/alias net-repo-enable=.*//g' /root/.bashrc
cat <<"EOF">> /root/.bashrc
alias net-repo-enable='/usr/local/bin/net-repo-enable.sh'
# Removing old alias "cd-repo-enable" if detected
sed -i 's/alias cd-repo-enable=.*//g' /root/.bashrc
cat <<"EOF">>/root/.bashrc
alias cd-repo-enable='/usr/local/bin/cd-repo-enable.sh'
# Applying changes
source ~/.bashrc
echo "Installation sucess"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy