Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have just updated the kernel, meaning I have two sets of kernel files at the moment; and I'd like to use the command line to remove the old one.

I'm aware that I can use apt-show-versions to show which packages I have installed which are named linux*:

$ apt-show-versions -r linux*
libselinux1/natty uptodate 2.0.96-1ubuntu2
linux-firmware/natty uptodate 1.52
linux-generic/natty uptodate 2.6.38.10.25
linux-headers-2.6.38-10/natty uptodate 2.6.38-10.46
linux-headers-2.6.38-10-generic/natty uptodate 2.6.38-10.46
linux-headers-2.6.38-8/natty uptodate 2.6.38-8.42
linux-headers-2.6.38-8-generic/natty uptodate 2.6.38-8.42
linux-headers-generic/natty uptodate 2.6.38.10.25
linux-image-2.6.38-10-generic/natty uptodate 2.6.38-10.46
linux-image-2.6.38-8-generic/natty uptodate 2.6.38-8.42
linux-image-generic/natty uptodate 2.6.38.10.25
linux-libc-dev/natty uptodate 2.6.38-10.46
linux-sound-base/natty uptodate 1.0.24+dfsg-0ubuntu1
pptp-linux/natty uptodate 1.7.2-6
syslinux/natty uptodate 2:4.02+dfsg-7ubuntu1
syslinux-common/natty uptodate 2:4.02+dfsg-7ubuntu1
util-linux/natty uptodate 2.17.2-9.1ubuntu4

From this I can see I have kernel files from 2.6.38-8 and from 2.6.38-10.

Is there an apt command where I could specify something like 'version=2.6.38-8*'; and it lists all packages that match that version number (regardless of name)?

The reason I'm asking for this is that I'd like to be able to check if I have packages installed say with version 2.6.38-8* - but which do not start with linux*.

I'm not sure if there are such files now, but I'm pretty sure I've had this problem before, which is why now I always first search for linux* in Synaptic, and then separately search for version number of the package I want to remove, and sort by installed, and remove all in one take. I'd just like to be able to do the same from the command line.

share|improve this question

migrated from stackoverflow.com Jul 14 '11 at 23:46

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 1 down vote accepted

How's this?:

apt-show-versions | grep 2.6.28-8
share|improve this answer
    
Thanks for that @Chris Acheson - the thing is, there could be packages that have 2.6.28-8*, but do not start with linux*; thus, I'd like a "second pass", where I search only for version numbers like in Synaptic (this wasn't in the original question, but I added an edit to the OP). Thanks again, cheers! –  sdaau Jul 14 '11 at 23:59
1  
That should find all packages by version number, regardless of name. It takes the whole list from apt-show-versions, and filters out any lines that don't contain "2.6.28-8". If you wanted to specifically not find packages that start with linux, you could do: apt-show-versions | grep 2.6.28-8 | grep -v ^linux –  Chris Acheson Jul 15 '11 at 0:04
    
Indeed - sorry about that, @Chris Acheson, I misread your answer at first; accepted now :) Thanks - cheers! –  sdaau Jul 15 '11 at 0:35

It is also possible to use aptitude to perform fairly complex searches using its own built-in query syntax, e.g.

$ aptitude search '?version(2\.6\.38)'

See the search section of the Aptitude manual for more information about the search syntax.

share|improve this answer
    
Many thanks for that, @OrbWeaver - I haven't used aptitude much (probably because a long time I read somewhere that I should use apt-get instead) - however, just tried it, seems to work :) Cheers! –  sdaau Aug 2 '11 at 14:52

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.