Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While doing some support audits I'd like to know what would be the most efficient/compact way to get a list of all extra reporitories being used on a given Ubuntu workstation using command line (not via the GUI tools). So far I am using:

  • diff'ing a standard sources.list file against the workstation's
  • examining files under cat /etc/apt/sources.list.d

Any other ideas on how to best go about this ?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

To examine the files under /etc/apt/sources.list.d, you could use:

cat /etc/apt/sources.list.d/*.list | grep -v "^#"

This reads out the contents of all the files there and then cuts out all commented out lines. This way you only get the repositories that are actually in use.

share|improve this answer
1  
Thanks Andrew! I'll expand the above to also look into sources.list as older installs or external script may still add to it too. I was hoping some apt command would provide the information but this is as good. –  MagicFab May 20 '11 at 14:38

Using the existing apt python modules, you can write a very small script:

###################################################################    
##################file: apt-listsources############################
###################################################################
#!/usr/bin/python
import sys

from aptsources.sourceslist import SourcesList, SourceEntry

if __name__ == "__main__":

    list=SourcesList()
    for l in list.list:
        if l.invalid or l.disabled:
           continue
        print l.line
##################################################################            
share|improve this answer
    
Can you explicitly tell what your script does and what are its input/output ? It will be nice for non-python users. Thank you –  NorTicUs Oct 23 '12 at 9:39

You could open software sources (In the edit menu of the software center) and then switch to other software tab .

enter image description here

share|improve this answer

If you open software-properties-gtk, the Other Software tab will show a list of the extra repositories being used.

software-properties-gtk can be opened by opening Update Manager and selecting settings, or opening the Software Center, Edit -> Software Sources ...

enter image description here

share|improve this answer
    
Sorry if I wasn't clear in my question, I meant using command line (edited), not GUI tools - tx. anyways! –  MagicFab Apr 5 '11 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.