PDA

View Full Version : Just found a handy command:



Timmer1240
January 3rd, 2011, 04:24 AM
To remove all the unused Linux Kernel headers, images and modules, simply run this command: dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

CharlesA
January 3rd, 2011, 04:27 AM
Nice one. That's a bit easier then the way I was doing it. :)

Timmer1240
January 3rd, 2011, 04:30 AM
Lot of useful things here! http://www.webupd8.org/

cariboo
January 3rd, 2011, 05:11 AM
If you are running Natty, and are a synaptic user, it marks older kernels as obsolete the next time you run it after installing a new kernel and rebooting.

CharlesA
January 3rd, 2011, 05:12 AM
If you are running Natty, and are a synaptic user, it marks older kernels as obsolete the next time you run it after installing a new kernel and rebooting.
Does that affect the way dpkg sees them?

Just curious, as I haven't checked out Natty yet.

Timmer1240
January 3rd, 2011, 05:17 AM
I just might have to upgrade someday I guess Im still using and loving Karmic 9.10 but support is going to end soon. Im not sure if I like the new unity desktop I just love gnome and how easy and intuitive it is but will upgrade sooner or later maybe in April.

wojox
January 3rd, 2011, 05:21 AM
All but the current and second most run from the command line:


OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | \
awk '"'"'{print "linux-image-" $0}'"'"' )
if [ -n "$OLD" ]; then
apt-get -qy remove --purge $OLD
fi
apt-get -qy autoremove --purge

ki4jgt
January 3rd, 2011, 06:20 AM
Awesome. I just lost 395 megs :-)

theraje
January 3rd, 2011, 07:19 AM
That is handy! In fact, I think I'll commit it to memory.

...

As if. :P

earthpigg
January 3rd, 2011, 07:28 AM
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

is there a website that explains all the s/\(.*\)-\( stuff?

i see it a lot and it is clearly powerful, flexible, and robust as hell, but i don't even know what it is called, so have no idea how to google it.

mkendall
January 3rd, 2011, 07:31 AM
Try a search for "sed tutorial"

oldos2er
January 3rd, 2011, 07:41 PM
If you are running Natty, and are a synaptic user, it marks older kernels as obsolete the next time you run it after installing a new kernel and rebooting.

Wow. I hope this behavior is configurable (i.e., can be disabled).

cariboo
January 3rd, 2011, 08:05 PM
Does that affect the way dpkg sees them?

Just curious, as I haven't checked out Natty yet.

Dpkg was updated to 1.15.8.7ubuntu1, but I don't see anything in the change logs about changing the way it looks at packages.

CharlesA
January 3rd, 2011, 08:19 PM
Dpkg was updated to 1.15.8.7ubuntu1, but I don't see anything in the change logs about changing the way it looks at packages.
Thanks. :)

ceramicm
January 3rd, 2011, 08:41 PM
is there a website that explains all the s/\(.*\)-\( stuff?

i see it a lot and it is clearly powerful, flexible, and robust as hell, but i don't even know what it is called, so have no idea how to google it.

This (http://sed.sourceforge.net/sed1line.txt) is a pretty handy guide to sed (http://en.wikipedia.org/wiki/Sed).

CharlesA
January 3rd, 2011, 08:52 PM
This (http://sed.sourceforge.net/sed1line.txt) is a pretty handy guide to sed (http://en.wikipedia.org/wiki/Sed).

I have that one bookmarked, it's very handy indeed. :)

wojox
January 3rd, 2011, 08:55 PM
This (http://sed.sourceforge.net/sed1line.txt) is a pretty handy guide to sed (http://en.wikipedia.org/wiki/Sed).

That is a nice cheatsheet. :p

earthpigg
January 3rd, 2011, 09:43 PM
This (http://sed.sourceforge.net/sed1line.txt) is a pretty handy guide to sed (http://en.wikipedia.org/wiki/Sed).

thank you, sir.

chriswyatt
January 3rd, 2011, 10:30 PM
That's saved me over a gigabyte of hard drive space. Nice :)

sdowney717
January 3rd, 2011, 10:56 PM
oh wow, that took forever to run and left a possible error??
just posting what was left of terminal but there was so much more!

free space before 201.2
free space after 203.3


Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.32-20-generic
Found initrd image: /boot/initrd.img-2.6.32-20-generic
Found linux image: /boot/vmlinuz-2.6.32-19-generic
Found initrd image: /boot/initrd.img-2.6.32-19-generic
Found linux image: /boot/vmlinuz-2.6.32-18-generic
Found initrd image: /boot/initrd.img-2.6.32-18-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-17-generic, directory '/lib/modules/2.6.32-17-generic' not empty so not removed.
Removing linux-image-2.6.32-18-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-18-generic /boot/vmlinuz-2.6.32-18-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-18-generic /boot/vmlinuz-2.6.32-18-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-18-generic /boot/vmlinuz-2.6.32-18-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.32-20-generic
Found initrd image: /boot/initrd.img-2.6.32-20-generic
Found linux image: /boot/vmlinuz-2.6.32-19-generic
Found initrd image: /boot/initrd.img-2.6.32-19-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-18-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-18-generic /boot/vmlinuz-2.6.32-18-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-18-generic /boot/vmlinuz-2.6.32-18-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.32-20-generic
Found initrd image: /boot/initrd.img-2.6.32-20-generic
Found linux image: /boot/vmlinuz-2.6.32-19-generic
Found initrd image: /boot/initrd.img-2.6.32-19-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-18-generic, directory '/lib/modules/2.6.32-18-generic' not empty so not removed.
Removing linux-image-2.6.32-19-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-19-generic /boot/vmlinuz-2.6.32-19-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-19-generic /boot/vmlinuz-2.6.32-19-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-19-generic /boot/vmlinuz-2.6.32-19-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.32-20-generic
Found initrd image: /boot/initrd.img-2.6.32-20-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-19-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-19-generic /boot/vmlinuz-2.6.32-19-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-19-generic /boot/vmlinuz-2.6.32-19-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.32-20-generic
Found initrd image: /boot/initrd.img-2.6.32-20-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-19-generic, directory '/lib/modules/2.6.32-19-generic' not empty so not removed.
Removing linux-image-2.6.32-20-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-20-generic /boot/vmlinuz-2.6.32-20-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-20-generic /boot/vmlinuz-2.6.32-20-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-20-generic /boot/vmlinuz-2.6.32-20-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-20-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-20-generic /boot/vmlinuz-2.6.32-20-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-20-generic /boot/vmlinuz-2.6.32-20-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-20-generic, directory '/lib/modules/2.6.32-20-generic' not empty so not removed.
Removing linux-image-2.6.32-21-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-21-generic /boot/vmlinuz-2.6.32-21-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-21-generic /boot/vmlinuz-2.6.32-21-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-21-generic /boot/vmlinuz-2.6.32-21-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-21-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-21-generic /boot/vmlinuz-2.6.32-21-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-21-generic /boot/vmlinuz-2.6.32-21-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-21-generic, directory '/lib/modules/2.6.32-21-generic' not empty so not removed.
Removing linux-image-2.6.32-22-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-22-generic /boot/vmlinuz-2.6.32-22-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-22-generic /boot/vmlinuz-2.6.32-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-22-generic /boot/vmlinuz-2.6.32-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-22-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-22-generic /boot/vmlinuz-2.6.32-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-22-generic /boot/vmlinuz-2.6.32-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-22-generic, directory '/lib/modules/2.6.32-22-generic' not empty so not removed.
Removing linux-image-2.6.32-23-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-23-generic /boot/vmlinuz-2.6.32-23-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-23-generic /boot/vmlinuz-2.6.32-23-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-23-generic /boot/vmlinuz-2.6.32-23-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-23-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-23-generic /boot/vmlinuz-2.6.32-23-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-23-generic /boot/vmlinuz-2.6.32-23-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-23-generic, directory '/lib/modules/2.6.32-23-generic' not empty so not removed.
Removing linux-image-2.6.32-24-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.32-24-generic /boot/vmlinuz-2.6.32-24-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-24-generic /boot/vmlinuz-2.6.32-24-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-24-generic /boot/vmlinuz-2.6.32-24-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.32-24-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-24-generic /boot/vmlinuz-2.6.32-24-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-24-generic /boot/vmlinuz-2.6.32-24-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
dpkg: warning: while removing linux-image-2.6.32-24-generic, directory '/lib/modules/2.6.32-24-generic' not empty so not removed.
Removing linux-image-2.6.35-22-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
Purging configuration files for linux-image-2.6.35-22-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Removing linux-image-2.6.35-23-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-24-generic
Found initrd image: /boot/initrd.img-2.6.35-24-generic
Found linux image: /boot/vmlinuz-2.6.28-15-generic
Found initrd image: /boot/initrd.img-2.6.28-15-generic
Found linux image: /boot/vmlinuz-2.6.28-14-generic
Found initrd image: /boot/initrd.img-2.6.28-14-generic
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
done
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old
you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old
you may need to re-run your boot loader[grub]
Purging configuration files for linux-image-2.6.35-23-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic

infestor
January 3rd, 2011, 11:41 PM
To remove all the unused Linux Kernel headers, images and modules, simply run this command: dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

regexp wins again :D

bodhi.zazen
January 4th, 2011, 02:51 AM
is there a website that explains all the s/\(.*\)-\( stuff?

i see it a lot and it is clearly powerful, flexible, and robust as hell, but i don't even know what it is called, so have no idea how to google it.

It is IMO helpful to learn "regular expressions"

http://linuxreviews.org/beginner/tao_of_regular_expressions/

http://www.zytrax.com/tech/web/regex.htm

http://www.linuxjournal.com/article/6324

Used by sed, grep, awd, nginx, perl, the list goes on ...

phrostbyte
January 4th, 2011, 03:48 AM
is there a website that explains all the s/\(.*\)-\( stuff?

i see it a lot and it is clearly powerful, flexible, and robust as hell, but i don't even know what it is called, so have no idea how to google it.

"regular expressions"

phrostbyte
January 4th, 2011, 03:50 AM
Wow, and I thought I was being so clever. I swear this thread was still on page one in my view.

:lolflag: 8-[ 8-[ 8-[ 8-[

earthpigg
January 4th, 2011, 07:44 AM
"regular expressions"

really?

and two people said this?

who the hell named this?

CharlesA
January 4th, 2011, 03:12 PM
who the hell named this?

That's just the name for it, not sure who named it, but the idea is that it does pattern matching.

Always makes me think of this:

http://imgs.xkcd.com/comics/regular_expressions.png

inobe
January 4th, 2011, 03:50 PM
very nice, saved me some work


edit: any more of the good stuff ?

inobe
January 5th, 2011, 03:33 PM
does anyone know how to put that command together and explain what it does ?

mlnease
July 22nd, 2011, 03:40 AM
To remove all the unused Linux Kernel headers, images and modules, simply run this command: dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
Thanks! This helped me to get rid of one old kernel but not a couple others (please see attached)--any further advice?

Thanks in Advance,

mike

CharlesA
July 22nd, 2011, 06:38 PM
does anyone know how to put that command together and explain what it does ?

It uses sed to do pattern matching of the output of dpkg -l, other then that, I can't really explain much.


Thanks! This helped me to get rid of one old kernel but not a couple others (please see attached)--any further advice?

Thanks in Advance,

mike

You could try using the one I got working - modified from the one the OP posted.


dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1 | xargs apt-get purge --assume-yes

mlnease
July 22nd, 2011, 06:49 PM
It uses sed to do pattern matching of the output of dpkg -l, other then that, I can't really explain much.



You could try using the one I got working - modified from the one the OP posted.


dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1 | xargs apt-get purge --assume-yes

Thanks! Got an interesting result.
First, mn@mn-desktop:~$ sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1 | xargs apt-get purge --assume-yes
[sudo] password for mn:
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
mn@mn-desktop:~$So I opened a gksudo nautilus and tried changing the permissions on /var/lib/dpkg/lock and received this:
mn@mn-desktop:~$ gksudo nautilus
Initializing nautilus-gdu extension
Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error No such file or directory
Please ask your system administrator to enable user sharing.

nautilus: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
mn@mn-desktop:~$Any clue?

CharlesA
July 22nd, 2011, 06:52 PM
Do you have another package manager open?

Have you already rebooted?

mlnease
July 22nd, 2011, 07:03 PM
Do you have another package manager open?

Have you already rebooted?

First, thanks again for your time an interest. Yes, I've run update-grub and update-grub2 and rebooted--the grub screen remains the same and no, I had no other package manager open. I find now that I'm able to access var/lib/dpkg via gksudo nautilus (your code returns the same error message as above); but I'm a bit nervous about tampering with the permissions without knowing what I'm doing. Any suggestions?

halj32
July 22nd, 2011, 07:23 PM
I think that you may need to add sudo to the line to run as root

CharlesA
July 22nd, 2011, 07:29 PM
Ah. I got the same error before I tried adding sudo before apt-get:


dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1 | xargs sudo apt-get purge --assume-yes

cariboo
July 22nd, 2011, 08:57 PM
If you are using a recent version of Ubuntu, you have to run:


sudo update-grub

to remove the unsued kernel entries

mlnease
July 22nd, 2011, 09:03 PM
Ah. I got the same error before I tried adding sudo before apt-get:


dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1 | xargs sudo apt-get purge --assume-yes
Bravo, yes, that made it run--but the entries are still there, even after running sudo update-grub and rebooting.

But I hate to take any more of your time on this--thanks a million just the same.

mlnease
July 22nd, 2011, 09:07 PM
Thanks, yes, I've run 'sudo update-grub' and 'sudo update-grub2' repeatedly, to no effect. By the way, if I enter 2.6.38-8 or 2.6.38-10 in the Synaptic search window, nothing comes up. Odd, no?

mlnease
July 22nd, 2011, 09:09 PM
By the way, I've just been copying and pasting your code--should I be replacing any characters, such as '( uname'? Sorry but the code is all Greek to me...

CharlesA
July 22nd, 2011, 09:09 PM
Nah it can be run as is.

Strange that it's not updating the grub menu.

What is the output when you run update-grub?

Here's what mind looks like:

charles@Thor:~$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-33-server
Found initrd image: /boot/initrd.img-2.6.32-33-server
Found linux image: /boot/vmlinuz-2.6.32-32-server
Found initrd image: /boot/initrd.img-2.6.32-32-server
Found memtest86+ image: /boot/memtest86+.bin
done

mlnease
July 22nd, 2011, 09:11 PM
Strange.

What is the output when you run update-grub?


mn@mn-desktop:~$ sudo update-grub
[sudo] password for mn:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-33-generic
Found initrd image: /boot/initrd.img-2.6.32-33-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Ubuntu 11.04 (11.04) on /dev/sda1
done
mn@mn-desktop:~$

CharlesA
July 22nd, 2011, 09:18 PM
That looks normal. Does the grub menu still have the extra entries?

Also are you dual booting?

mlnease
July 22nd, 2011, 09:42 PM
That looks normal. Does the grub menu still have the extra entries?

Also are you dual booting?

Yes, attached is a shot of the grub screen from a minute ago; and yes, I'm dual-booting with Lucid and Natty.

Bandit
July 22nd, 2011, 10:12 PM
is there a website that explains all the s/\(.*\)-\( stuff?

i see it a lot and it is clearly powerful, flexible, and robust as hell, but i don't even know what it is called, so have no idea how to google it.

Dont know about websites, but its defined in the Linux+ study guide by Sybex. Have to learn those types of CLI info to pass the exam.. Pray for me.. :(

CharlesA
July 22nd, 2011, 10:15 PM
Yes, attached is a shot of the grub screen from a minute ago; and yes, I'm dual-booting with Lucid and Natty.

Try booting into Natty and seeing which kernels are installed there.

cariboo
July 23rd, 2011, 01:33 AM
As CharlesA said boot into your other installation, the command won't work on an installation that isn't running.

mlnease
July 23rd, 2011, 01:36 AM
Thanks, both--I've tried that with the same result. I'm in Natty now but am downloading a lot of package files over a very slow connection--soon as I'm able, I'll run update-grub again, restart and post my results.

Thanks for your continued attention.

mlnease
July 23rd, 2011, 02:41 AM
OK, back in Natty--ran the code in #35 again, ran update-grub and restarted--same results.

Guys, it isn't like this is a major problem, just a graphic annoyance (I think)--I really appreciate all the help but maybe it's time to just live with it.

Thanks again for all your time.

CharlesA
July 23rd, 2011, 04:29 AM
Curious - what happens if you pick one of the other kernels?

vrhahaha
July 23rd, 2011, 04:39 AM
hi mlnease,

I've had the same situation before

sudo grub-mkconfig -o /boot/grub/grub.cfg

then proceed to update-grub solved mine

I hope that can help you

mlnease
July 23rd, 2011, 06:12 PM
Good question--why didn't I think of that? I get a black screen with 'Error-file not found' for both 2.6.38-8 and 2.6.38-10.

mlnease
July 23rd, 2011, 06:14 PM
Thanks, vhrahaha--I tried it but the grub screen remains unchanged.

CharlesA
July 23rd, 2011, 06:24 PM
Good question--why didn't I think of that? I get a black screen with 'Error-file not found' for both 2.6.38-8 and 2.6.38-10.
I wonder where it's pulling the Grub menu from.


locate menu.lst

You could also post what the contents of /boot/grub/grub.cfg are.

zer010
July 23rd, 2011, 06:33 PM
I've found this thread quite interesting and informative. Thanks to all who posted. Currently, I'm running Xubuntu 11.04 and even after some kernel upgrades, I don't get the older kernels listed in GRUB2.

I'm also interested in where mlnease's grub is getting it's listing from. I've never had an issue like that before..

mlnease
July 23rd, 2011, 07:32 PM
I wonder where it's pulling the Grub menu from.


locate menu.lstYou could also post what the contents of /boot/grub/grub.cfg are.


mn@mn-OptiPlex-745:~$ locate menu.lst
/usr/share/doc/memtest86+/examples/grub-menu.lst
mn@mn-OptiPlex-745:~$ sudo /boot/grub/grub.cfg
[sudo] password for mn:
sudo: /boot/grub/grub.cfg: command not found
mn@mn-OptiPlex-745:~$

CharlesA
July 23rd, 2011, 07:34 PM
Ah, good no menu.lst.

Run this:


gedit /etc/grub/grub.cfg

mlnease
July 23rd, 2011, 07:37 PM
Here's /user/share/doc/memtest86+/examples/grub-menu.lst:
# sample /boot/grub/menu.lst entry for memtest86
#
# This example assumes the contents of /boot is on the root partition.
# If your /boot is on its own partition, remove /boot from the 'kernel' line.

title memtest86+
root (hd0,0)
kernel /boot/memtest86+.bin

title memtest86+ (serial console 115200)
root (hd0,0)
kernel /boot/memtest86+.bin console=ttyS0,115200n8

mlnease
July 23rd, 2011, 07:38 PM
Ah, good no menu.lst.

Run this:


gedit /etc/grub/grub.cfg

Done--it's blank.

CharlesA
July 23rd, 2011, 07:39 PM
Whoops, it should have been /boot/grub/grub.cfg.

Shouldn't multitask when posting.

Lucid As A Lynx
June 1st, 2012, 11:31 AM
My boot drive was so full ubuntu couldn't install updates.
This command got me 2.5Gb back and now all is well :-)

not found
June 1st, 2012, 11:42 AM
Thread closed.


404