11

I was trying to get musepack encoder support built into ffmpeg today, and I inadvertently broke a few things but I'm not sure exactly which package I installed which broke them. How can I remove ALL packages I installed today, and start again from scratch more carefully?

I can see a list of them in "Ubuntu Software Center" under today's date in the "History", but I don't want to go through uninstalling them one-by-one, because there are hundreds to do.

wim
  • 13,088

3 Answers3

18
grep -e `date +%Y-%m-%d` /var/log/dpkg.log | awk '/install / {print $4}' | uniq | xargs apt-get -y remove

found on commandlinefu worked fine for me

6

The file /var/log/apt/history.log has what you need. Take a look at the answer: How to reinstall many removed packages at once? it's a more detailed answer.

waltinator
  • 37,856
2

Disclaimer: Nala is still in a development stage, and is not recommended for any professional use.

For apt packages

If you're ready to use the command line to install new packages, it's possible to get an easy undo feature with the more modern apt front-end called nala (for 22.04 you have to enable the "universe" repository). Note: This will only work for apt/.deb packages.

sudo apt install nala

From this point, use nala to install new packages on your system, using:

sudo nala install <package-name>

Leave security updates etc. to the unattended-upgrades package.

Now, when you run the command nala history, you get a list of the commands run with nala, including installed packages. To filter only new installations, use:

nala history | grep install

An added bonus of the history feature is that you can undo any step in the history, so that you can easily reverse package installation procedures. This can be done by issuing the command:

sudo nala history undo <ID>

Where <ID> is the ID number of the transaction in the history list you want to undo.

For snap packages

Snap has its own "undo" feature, where you can easily revert to the previously installed version. This is done with:

sudo snap revert <package-name>

In case you want to revert to a specific revision of a snap package, this can be stated as well;

sudo snap revert <package-name> --revision <rev ID>

For snaps, also see here.

Artur Meinild
  • 31,035