Previous 3 / 3


  1. Rich

    Used the 'very long command'

    "dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge"

    Worked like a charm. Plenty of space in /boot

  2. Alessandro

    Hi to all!

    When i try the dry-run command I recive:
    The following packages have unmet dependencies:
    linux-image-generic-lts-quantal : Depends: linux-image-3.5.0-54-generic but it is not going to be installed
    E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

    Mine kernel is 3.5.0-45, but I don't know what is the package that depend from them...
    I can't use apt-get -f install because my boot partition is full..
    Can anyone help me please ?
    Thank you very much, and apologize for my bad english!

  3. kim jong oun

    this worked a treat. my /boot was full and giving issues on ubuntu 12.04.04 AMD 64bit. i was crapping myself trying to fix this, but the one liner worked!

  4. john herring

    Thank you so much for this command. It worked perfectly! I had searched for hours to find a simple solution to the boot space problem.

  5. CJ

    After confirming with "--dry-run remove" that only images and headers would be removed in my 12.04 64 bit system, I pulled the trigger.
    The last line of the result is "Do you want to continue [Y/n]? Abort." and I'm returned to the prompt as if I'd aborted the command.
    Haven't got a clue what went wrong.

    This command:
    dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get remove

  6. P B
    • Linerd

      Thanks for your comment.

      So, inserting a

      grep -v libc

      will fix it in the case of libc-dev:amd64. Maybe I should make it so it only includes packages that start with "linux-image" or "linux-headers", just in case some other problem package shows up. I can do that by adding

      grep -E "(image|headers)"
      • P B

        Cheers for that. Maybe you could modify the date at the top of the page. It currently says October 2nd 2010 which gives a first impression that it's 3 years old. And under the Updates include this latest tweak.

  7. P B

    It is only supposed to match kernel related packages but it is also finding packages like linux-libc-dev:amd64. As it begins with linux and has a number. People could get caught out with this and
    remove things they dont want removing.

    • Linerd

      That makes the dry run that much more important.

  8. Augusto

    You are awesome
    You wrote this post three years ago and it is working
    thanks so much

  9. Van Bastos

    I love you man. hahaha it really worked.

    Thanks for you very long command

    "dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge"


  10. Thanks for this helpful command! However, I have one remark:

    I also have linux-libc-dev:amd64 installed, which became a candidate for removal because of the last check "only keep items with numbers in them". Of course, including "grep -v libc" in the command solved this.

    • Some Dummy

      Or cut -f1,1 -d":". Also it may help to pray that the Linux people choose not to use numbers in any other necessary packages.

  11. Vitalie Ciubotaru

    a nice command line one-liner that removes all but the currently running kernel
    While this is an accurate description, it might not be what we want. Imagine the following situation:
    1. I do `sudo apt-get update` and see that a new kernel is available.
    2. I install the new kernel. I don't reboot (why would I, if everything works fine?)
    3. I realize that I have a bunch of older kernels in my system. I want to remove them.
    4. I run this one-liner. Instead of deleting everything except the newest kernel, it deletes everything except the currently running one. No gain.

    • Linerd

      Why do you say no gain? You still got rid of all of those old kernels, didn't you? And removing the running kernel certainly seems like a bad idea. In your scenario, the next time you install updates you should get the new kernel again. Now you only have one extra kernel rather than 5 or 10.

  12. Nik


  13. vacri

    Be careful, this will hit other packages as well - on my system (ubuntu 13.04) it also grabs "linux-libc-dev:amd64".

    ... which is pretty much what Rambo just said.

  14. Rambo

    Hmm I think it willl work on a 64 system, im currently in the process of adjusting it a little though. The trick of picking out everything that contain numbers for processing doesnt work on 64 systems since we have filenames like *amd64 and so.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>