Getting Ubuntu Repository list
Want to list the repositories in Ubuntu to see where you are getting the packages from? Here's how to do that.
Repositories are nothing but from where the packages are fetched and it can be anything from a third party repo to a PPA.
There are multiple cases where you want to list repositories such as you're troubleshooting issues related to repositories.
And in this tutorial, I will walk you through how you can list added repositories of your system.
List Ubuntu repositories
Whenever you add an external repository or PPA, all the details including their GPG keys are stored inside the /etc/apt
directory.
So the whole tutorial will revolve around how you list the content of /etc/apt
and further directories to know added directories.
The repository details are in the /etc/apt/sources.list file (for official Ubuntu repositories) and in the sources.list files inside the /etc/apt/sources.list.d directory.
You can manually check the content of the individual files, or you can be smart and use grep to get them all in one place:
grep -rhE ^deb /etc/apt/sources.list*
Here, I have used the grep command with regular expressions and specific patterns to lines starting with deb
and gets data from the /etc/apt/sources.list*
file.
Alternatively, you can have the same effect with less clutter using the apt-cache command:
apt-cache policy
List external repositories and PPAs only
The above method showed how you list all the repositories including internal, external, and PPAs. But what if you only want to list external ones?
Well, that's pretty simple.
To list external repositories and PPAs, you can list the content of the /etc/apt/sources.list.d/
directory using the ls command:
ls /etc/apt/sources.list.d/
List PPAs only
If you want to list PPAs only, then you can list the contents of the /etc/apt/sources.list.d/
directory and use the grep command to filter output:
cat /etc/apt/sources.list.d/*.list | grep "ppa"
You may ignore lines starting with the #
tag. This means there are two PPAs in my system: graphics-drivers and Xubuntu-dev.
Here's how to remove repositories in Linux
Once you know added repositories of your system, you may find some unnecessary ones, But how would you remove them?
Well, here's a simple guide on how to remove software repositories from Ubuntu:
I hope you will find this guide helpful.