Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've read How to solve "Extra junk at end of file" when using apt? and though it's a similar problem, it apparently has a different cause since, looking at the contents of the file, unlike in the earlier Q&A it seems far from obvious that adding apostrophes could solve the issue.

enter image description here

enter image description here

An error occurred, please run Package Manager from the right-click menu or apt-get in a terminal to see what is wrong. The error message was: 'Unknown Error: '' (E: Syntax error /etc/apt/apt.conf.d/01autoremove-kernels:1: Extra junk at end of file)'. This usually means that your installed packages have unmet dependencies.

Contents of problematic /etc/apt/apt.conf.d/01autoremove-kernels (please note, however, that gedit complains about invalid characters):

share|improve this question
up vote 3 down vote accepted

Found a solution which also worked for me:

sudo /etc/kernel/postinst.d/apt-auto-removal

which will first return the above error yet again and secondly and crucially cleanly re-write the problematic file, to be finished off by something along the lines of

sudo apt-get update && sudo apt-get dist-upgrade

Contents of problematic /etc/apt/apt.conf.d/01autoremove-kernels

  • before applying the above mentioned "recovery":
  • after applying the above mentioned "recovery":
// File autogenerated by /etc/kernel/postinst.d/apt-auto-removal, do not edit
share|improve this answer

Your Answer


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.