I know how to do it on Red Hat based systems.

 yum –disablerepo=*  --enablerepo=epel update

The above command will temporarily disable all repos and enable epel and update only epel packages.

 yum update–disablerepo=remi-safe,updates

This will also disable two repos while updating all other enable repos.

What is the equivalent of the above on ubuntu for instance ?

I know we can comment out the repo in the /etc/apt/sources.list.d

But this will permanently disable the repo right?

Is there a way that I can run apt-get update while temporarily disable one repo for instance?

2 Answers 2


The easiest way I've found to manage repos is to have them in individual files in /etc/apt/sources.list.d/. That way, disabling the repo is as easy as moving the file from /etc/apt/sources.list.d/repo.list to /etc/apt/sources.list.d/repo.list.bak, and re-enabling the repo is as easy as going the other way. You could even create a script which temporarily disables a repo by moving the file, running update/install/whatever, and then moving the file back again.

  • 5
    … or, if one is used to .bak files being discardable byproducts of various tools, .disabled. (-:
    – JdeBP
    Commented Apr 30, 2018 at 7:10
  • I just tried with .disabled because some repos were giving errors, but apt-get update still takes them into account. Any idea why? (I ended up removing them from the folder and it fixed it)
    – pHneutre
    Commented Nov 20, 2023 at 13:28

The original question was how to run apt with a repo disabled for just that one execution. There really isn't an easy way to do that. Technically you could give the apt command a different configuration using -o and/or -c options but that's probably more effort than it's worth.

Using the add-apt-repository command you can easily add and remove repos. This is the most practical way I can see to solve the original question.

If you're talking about one of the distribution components like restricted, universe, multiverse, etc. then you can use just that keyword:

sudo add-apt-repository --remove multiverse
sudo apt update
sudo apt install whatever
sudo add-apt-repository multiverse

Otherwise you'll need to use the complete deb line:

repo="deb http://some.repo.com/foo bionic main"
sudo add-apt-repository --remove "$repo"
sudo apt update
sudo apt install whatever
sudo add-apt-repository "$repo"

The --remove will remove the repo from sources.list as well as any .list files in sources.list.d. However, it should be noted that (unless your repo is in the form of ppa:user/somerepo) adding it again will put it in sources.list -- not in a file in sources.list.d.

You must log in to answer this question.

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