0

I accidentally purged XDG from my Raspbian Buster using this command: sudo apt purge -y xdg*

I've installed XDG and any other components back few minutes after the deed, and I thought I fixed it but I didn't. Plus I didn't realize the mess I'd done and closed out the terminal after that, so I wasn't able to take a screenshot of the apt log.

I'd like to request someone to send me a screenshot of doing sudo apt purge xdg* then at the prompt section take a screenshot, and send it to me here please, so that I may try to install the additional packages removed during the purge.

I've tried to install all the packages listed under Buster Full Packages here too: https://gist.github.com/jarvisms/6d3edba4fc27829d5dfe7a2bd8c7c5fb

But I still couldn't: 1) bring back how Raspbian Buster was; 2) get other system components running again. Been searching for any hint for days but I think this issue's pretty unique (uniquely dumb lol)

I honestly like this version of RPi now, it's more convenient to use (albeit sadly less efficient due to constant CPU maxing out for some reason) than how it was out of the box. But I can't program in C++ or Python properly, and figuring that out might take me more than attempting this since I'm not really a Linux connoisseur.

Thank you for reading.

4
  • why in the world would you want a screenshot of text? ... wouldn't the actual text be more useful?
    – jsotola
    Oct 18, 2021 at 3:23
  • 2
    There should be a log of what was removed in /var/log/apt/history.log. Oct 18, 2021 at 4:08
  • 1
    and in /var/log/dpkg.log (which is, IMO, easier to read and parse then apt's history.log. e.g. to list all packages purged today: awk '/^2021-10-18/ && $3 == "purge" {print $4}' /var/log/dpkg.log. And to reinstall them all apt install $(awk '/^2021-10-18/ && $3 == "purge" {print $4}' /var/log/dpkg.log)
    – cas
    Oct 18, 2021 at 5:11
  • note: dpkg.log is occasionally rotated, so you might need to use /var/log/dpkg.log.1 or /var/log/dpkg.log.2 etc.
    – cas
    Oct 18, 2021 at 5:18

1 Answer 1

1

dpkg, which is the program called by apt, apt-get, aptitude, etc to actually install or uninstall packages keeps a log file of its actions in /var/log/dpkg. This file is usually rotated monthly.

While it logs other things about what it's doing, it mostly logs actions it is taking for particular packages/versions in the following format:

2021-10-02 05:47:54 purge linux-image-5.10.0-4-amd64:amd64 5.10.19-1 <none>

The first two fields are date and time, the third is a verb (install, remove, purge, upgrade, configure, and more), the fourth is the package name, then the current package version (or <none> if it isn't installed yet) and the final field is the version of the package to be installed (or <none> if it isn't being upgraded).

This data is all you need to be able to re-install packages that you mistakenly removed or purged (or uninstall those you installed) on a particular day/time.

For example, you can list all the package names that you purged on a certain day & time (say, 5am on Oct 2 2021) with something like this:

# awk '/^2021-10-02 05:/ && $3 == "purge" {print $4}' /var/log/dpkg.log
linux-image-5.10.0-4-amd64:amd64
linux-image-5.9.0-5-amd64:amd64

You can use that output and command substitution to re-install them all (if they're still available in your repo):

# apt-get install $(awk '/^2021-10-02/ && $3 == "purge" {print $4}' /var/log/dpkg.log)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package linux-image-5.10.0-4-amd64:amd64
E: Couldn't find any package by glob 'linux-image-5.10.0-4-amd64'
E: Couldn't find any package by regex 'linux-image-5.10.0-4-amd64'
E: Unable to locate package linux-image-5.9.0-5-amd64:amd64
E: Couldn't find any package by glob 'linux-image-5.9.0-5-amd64'
E: Couldn't find any package by regex 'linux-image-5.9.0-5-amd64'

Unfortunately, these packages are now gone from the archive, having been replaced by newer kernel packages....which is why I purged them on that date (I'd been running newer kernels for long enough that I no longer needed to keep them installed just in case I had to revert to an older kernel).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .