Skip to content

Instantly share code, notes, and snippets.

@jrwren
Created January 14, 2022 16:50
Show Gist options
  • Save jrwren/11c4716a071b3bb41a730ec516d937f6 to your computer and use it in GitHub Desktop.
Save jrwren/11c4716a071b3bb41a730ec516d937f6 to your computer and use it in GitHub Desktop.
disable restricted, universe, multiverse in ubuntu server/cloud

If you are using a server or cloud image, you may not want to install the necessary packages to get add-apt-repository. /etc/apt/sources.list.d/ is empty by default so you can edit only /etc/apt/sources.list.

Without comments, OOTB docker image looks like this for me:

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security universe
deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse

It is unfortunate that the lines are mixed with single and multiple components and so we can't trivially filter only some lines.

something like: sed -E -i 's/ (restricted|multiverse|universe)//;s/^deb http:..(archive|security).ubuntu.com.ubuntu. bionic(-updates|-security)?$//' /etc/apt/sources.list will remove restricted, multiverse, and universe from the sources.list.

@jrwren
Copy link
Author

jrwren commented Feb 3, 2022

To keep universe but disable multiverse and restricted, use this: sed -E -i 's/ (restricted|multiverse)//;s/ multiverse//;s/ restricted//;s/^deb http:..(archive|security).ubuntu.com.ubuntu. bionic(-updates|-security)?$//' /etc/apt/sources.list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment