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.

I'd like to output a list of all currently not installed packages (they are visible in Synaptic for example) using only shell commands. How do I do this?

Thanks!

share|improve this question

2 Answers 2

up vote 4 down vote accepted

This should be it:

aptitude -F %p search '!~i'

This will list all packages currently not installed (including virtual packages and packages that have only their configuration files installed). If you don't want virtual packages (that's what Synaptic shows as Not installed), extend the search pattern to:

aptitude -F %p search '!~i!~v'

You probably need to install aptitude, as it's no longer part of the default installation as of Ubuntu 10.10.

share|improve this answer
    
Thanks, but does not list all (not installed) packages that lists synaptic :( –  BonboBingo Jan 24 '11 at 14:54
    
@htorque, your line lists all installed packages, not all not-installed packages –  Martin Owens -doctormo- Jan 24 '11 at 14:56
    
@BonboBingo: see update. –  htorque Jan 24 '11 at 15:03
    
@Martin Owens -doctormo-: no, it didn't. I asked dpkg to list all packages matching "*" (which I supposed were all packages), then filtered for "^.u", which are all packages currently in the Not-Installed state. –  htorque Jan 24 '11 at 15:10
1  
Instead of cutting out the package names afterwards, just have aptitude only display package names in the first place. aptitude --disable-columns -F %p search !~i. Alternatively also filter out virtual packages if they're not wanter. aptitude --disable-columns -F %p search !~i!~v –  geirha Jan 24 '11 at 22:41

This isn't fast, but it will work:

apt-cache pkgnames | xargs -i1 dpkg-query -f '${Package}\n' --show '1' 2>&1 | perl -lne 'if(/matching (.*)$/){ print $1 }'

Warning: This prints all packages, even meta-packages and virtual packages.

share|improve this answer
    
thanks but I also need those packages. –  BonboBingo Jan 24 '11 at 15:12
    
What are you trying to do exactly? It's very odd to find someone who wants to do this who isn't using python. I was also wrong, it does print meta packages (double checked man page) –  Martin Owens -doctormo- Jan 24 '11 at 15:13

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.