The APT is the package manager used on Ubuntu, responsible for handling software installation, updates, and removals. APT uses repositories (repos) as sources to fetch packages for installation. Obtaining a list of all installed repositories on Ubuntu is useful as it offers a clear overview of enabled software sources, ensuring users know the origins of their packages and have access to the latest updates and applications. This tutorial shows how to get installed repositories on Ubuntu.
To obtain a list of all installed repositories, you can use the following command:
sudo grep -rhE ^deb /etc/apt/sources.list*
Let's break down the command step by step:
grep- a command line tool for searching text patterns in files.
-r- option that informs to search for the pattern in directories and their subdirectories, effectively performing a recursive search.
-h- option that suppresses the display of file names in the output.
-E- option enables the use of extended regular expressions in the pattern. It allows you to use more advanced search patterns.
^deb- the pattern that is used to search for lines that start with
debin the files.
/etc/apt/sources.list*- the file pattern that specifies where
grepshould look for the pattern. It uses a wildcard
*to match all files starting with
/etc/apt/directory and its subdirectories.
Here's an example of the output you might see when running the command:
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted deb http://archive.ubuntu.com/ubuntu/ jammy universe deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe deb http://archive.ubuntu.com/ubuntu/ jammy multiverse deb http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu jammy-security main restricted deb http://security.ubuntu.com/ubuntu jammy-security universe deb http://security.ubuntu.com/ubuntu jammy-security multiverse ...