6

I want to see a list of repositories so that I have added to Ubuntu. How can I acquire such a list? Is there a command I can use?

5 Answers5

9

There are two different places in Debian for source list files: Most of the default source listings are in

/etc/apt/sources.list

While a few packages may add their own smaller lists to

/etc/apt/sources.list.d/

To view each of them, you can cat them individually. (like cat /etc/apt/sources.list, or cat /etc/apt/sources.list.d/*)

This is quite a familiar style in debian packaging. For instance apache keeps its common configuration in /etc/apache2/apache2.conf, while several other packages (like phpmyadmin) may add their own smaller configurations in /etc/apache2/conf.d/

Nemo
  • 9,460
5

All the repositories are listed in the .list files in the /etc/apt/sources.list.d/ directory.

abhshkdz
  • 3,989
1
grep -EvRH ^"$|\#" /etc/apt/source*
andrew.46
  • 38,003
  • 27
  • 156
  • 232
2cents
  • 11
  • 1
    I have added some extra formatting to your answer to enhance readability; could you expand a little on your answer? – andrew.46 Nov 14 '22 at 23:31
1

This command will list them quite clearly and nicely:

for X in /etc/apt/sources.list.d/*; do echo; echo; echo "** $X:"; echo; cat $X; done

(Here's an example of what the output can look like.)

You may also want to list the repositories configured in the master configuration file:

cat /etc/apt/sources.list
Eliah Kagan
  • 117,780
0

I use the following:

grep -Rh ^deb /etc/apt/sources.li* | sort -u
  1. grep -Rh ^deb /etc/apt/sources.li* prints every line starting with the word "deb" in /etc/apt/sources.list and every file in /etc/apt/sources.list.d. The R is for "recursive" and the h suppresses the filenames because I don't want to see them.
  2. sort -u sorts the input and removes duplicates. I put it in there because /etc/apt/sources.list.save exists on my system. I could probably delete it but it ain't hurtin' nuthin'.
MDeBusk
  • 1,175
  • 2
  • 8
  • 21