Skip to content

Instantly share code, notes, and snippets.

@sahildave
Created April 4, 2015 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahildave/caf9263de49f2d8d8471 to your computer and use it in GitHub Desktop.
Save sahildave/caf9263de49f2d8d8471 to your computer and use it in GitHub Desktop.
List all installed packages in ubuntu
#! /bin/sh
TEMPFILE=`tempfile`
cat /var/log/installer/initial-status.gz | gzip -d |grep '^Package:' | awk '{ print $2}' > $TEMPFILE
aptitude search -F %p '~i!~M' | awk '{ print $1}' | grep -v -F -f $TEMPFILE
rm $TEMPFILE
# Run the following to get a list of all the packages
# chmod +x installedpackages.sh
# ./installedpackages.sh > packages
@sahildave
Copy link
Author

To remove all the packages:

cat packages | xargs sudo apt-get purge -y

Add -s to simulate the run

sudo apt-get autoremove

to get rid of any dependencies that are no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment