Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Last active August 29, 2015 13:57
Show Gist options
  • Save lopesivan/9750148 to your computer and use it in GitHub Desktop.
Save lopesivan/9750148 to your computer and use it in GitHub Desktop.
With the following command you can obtain a list of installed packages, classified by priority:
dpkg-query -Wf '${Package;-40}${Priority}\n' | sort -b -k2,2 -k1,1
So, to remove all unneeded packages (optional and extra), you can execute the following command:
sudo apt-get --simulate purge $(dpkg-query -Wf '${Package;-40}${Priority}\n' |
awk '$2 ~ /optional|extra/ { print $1 }')
I added the --simulate option to be safe and see what apt says.
Strangely, it asks to remove also some required packages: e2fsprogs, util-linux, hostname and upstart, so it is necessary to reinstall these packages. I would download the packages in advance (apt-get download <packages>), to avoid network problems after.
Take also into account that for a working Wifi you can need some optional or extra package, removed in the above procedure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment