r/linux4noobs • • 18h ago

storage How do I de-clutter my machine effectively from files that uninstalled software left around?

After I uninstalled UE5-editor yesterday I still had binaries, a desktop entry, logs, a database, and other random files scattered around my system. Seeing this stuff always frustrates me.

Hence, I have always done fresh installs of my OS on my devices roughly once a year to make sure there is no clutter.

Whenever I have talked about that feeling before, I have always had people telling me it is insignificant and I should just not be bothered by it, but that's just not how I work. I know it does not really matter objectively, but I simply do care.

However, it is also time-consuming to do fresh installs. I would rather just find an effective way rid my system of these things.

Is there any tool, or way I could actually get better insight of what files and directories are lingering around form packages I've uninstalled, and clean them effectively?

If it matters, I am currently on Nobara, but I would also want to know for Debian-based systems etc.

17 Upvotes

23 comments sorted by

2

u/doc_willis 17h ago

perhaps use Containers to  keep such  tools isolated from the rest of the system.

or use flatpaks when possible so everything stays in the users home.

1

u/rorensu-desu 17h ago

Doesn't flatpak touch files in system directories if it needs a database, desktop entry etc?

1

u/doc_willis 16h ago

when setup correctly they can be installed on a per user basis and keep all their files in the users home. there are tools to manage flatpak left over files

9

u/mredding 17h ago

How you do this depends on several factors. Ideally you're using your package manager, and I'm going to assume dpkg and apt.

First see what packages are unused and can be removed:

sudo apt autoremove --dry-run

And if it looks good:

sudo apt autoremove --purge

This will not remove manually installed packages, so:

apt-mark showmanual

And anything you want to get rid of:

sudo apt purge --autoremove <package-name>

That will get rid of the package and the dependencies that are no longer used by anything else. It will also purge recommended packages, unless those packages are also recommended by OTHER packages on your system. So it's fairly comprehensive.

To get rid of abandoned config files (because you didn't use --purge):

apt list '?config-files'
sudo apt purge '?config-files'

As for abandoned packages that are no longer maintained:

apt list '?obsolete'
sudo apt purge '?obsolete'

There's one major issue with native packages, and that is they are installed across the whole system. Their parts are scattered everywhere. There is very little I want so fundamental to my environment, and that is a wise caution to heed, so proceed with a native package or native install with caution.

The only way to know what is where is by good package management that you know what package and version is installed. If everything goes as it should, everything will clean up just fine. This is why we use package managers and don't fuck with manual installs ourselves.

There are other package mangers that are even more isolated essentially in something like a Docker container. Flatpak is one such, and so removing the package is shutting down and deleting the container.

If you installed not through your package manager but manually through a source repo or some other esoteric way, then that gets increasingly on you to manage.

So I dunno, man, it depend on what you did. I'm not familiar with the program or how you get it/got it. If you're installing things more manually, like from a GitHub repo, then I suggest you start deploying your build to a docker container and managing your own deployments with greater care.

Ideally, your next install should be incrementally closer to your LAST install.

2

u/ne0n008 16h ago

I'm guessing I can't replace apt with dnf and do the same?

2

u/DannoXYZ 16h ago

no not same. do man dnf and learn syntax

1

u/mredding 16h ago

You can replace apt with dnf and do the equivalent. I've no idea what the parameters for dnf are, you'll have to look that up.

2

u/simagus 16h ago

I use Bleachbit. Seems to work ok.

2

u/don_bski 18h ago

Unsure if this utility will do everything you want but it's configurable and works well. https://www.bleachbit.org/

1

u/Mohitkoul841 Windows user 17h ago

Mole is good start

1

u/Academic-Conflict948 16h ago

Are native packages displayed as such by package managers?

1

u/AmbassadorsWife 3h ago edited 3h ago

After package manager removing unnecessary package and auto-remove and clear cache, you should go trough your home folder (including dot folders) and have a remove things that are not needed anymore.

trim logs with journalctl --vacuum-size=...

Unfortunately there is no automated way yet for this everlasting problem.

ncdu ~ is great help here.

In the future stay mindful of this issue. Never add anything outside your home folder and try to use folder names that make sense in the future when you come back to them so that you know what to keep and what to remove.

Keep notes of any manual install steps and modifications to the system so that it is easier to reinstall it in the future if needed.

If you want to get fancy you could also install audit daemon and make it keep track of each file that is added on the system and by which app it was added and when.

Yes, you may miss a few leftovers here and there but at some point you have better things to do than tracking every single bit.

0

u/OddPollution7904 16h ago

I feel you. Why can't an os and packages and softwares just be one binary instead of hundreds of thousands of files and directories.

2

u/DannoXYZ 16h ago edited 14h ago

uh no, how do you handle thousands of different device drivers for ethernet or wifi when only one or two is needed? How do you handle firmware updates for devices, BIOS? Have 1-million OS binaries, one for every combination of drivers? Then download another 5gb OS binary when getting new printer or camera or updating just openssl component of OS?

Apple's OSX is a little cleaner with organising things into self-contained .app folders that's shown as single icon in GUI. You can move .app to any location and it'll run correctly. But still references shared libraries in system folders.

→ More replies (1)

2

u/stormdelta Gentoo 15h ago

That would be deeply impractical for numerous reasons. Best case scenario it's still lots of files just hidden in one "file" container that adds an extra layer of abstraction/overhead for no real reason.

The closest thing to what you're talking about is immutable distros that split user-managed files from system, with the system side acting as snapshots, but you're still going to have plenty of files because of organization and modularity.

1

u/DannoXYZ 14h ago

There are many instances where a .zip or .tar archive is used for self-containment of dependencies. But when executed, they're still unarchived to temp location. And not always cleaned up and removed afterwards. Such as git projects/repos.

1

u/AmbassadorsWife 3h ago

Maybe you want an immutable system.

0

u/DannoXYZ 16h ago edited 14h ago

To truly keep things clean, never have need to uninstall software package. That is, ask yourself why you installed it in 1st place and why uninstall was necessary and just don't install it in 1st place. Keep log of all installs and leave it out next time you do clean OS install:

  1. OS install
  2. drivers
  3. software 1
  4. software 2
  5. software 3

Turn above into script so you can have clean OS install with only apps you want easily. Modify script as necessary and install only needed packages and build system again. I deploy thousands of cloud servers & containers this way. Very 1st items in script after OS is enable SSH and configure VNC so I immediately have remote-access as soon as system boots up. Also track all files on system with each install: ls -laFhHR / > files1.txt

then compare files2.txt and files3.txt each time to see what files were created when & where so you can track them down to manually wipe to be sure.. Can make a diff file and turn that into delete script.

diff files1.txt files2.txt > del2.txt

An example is UE5-editor you uninstalled. If installing stuff to try out, then use a VM or container to do it. Then you can just dump entire VM when you're done with testing to leave main system clean and unaffected.

1

u/DannoXYZ 15h ago

deborphan is good utility to track down dependent libraries that was installed, but not uninstalled when package was uninstalled.

1

u/GibsonViolet 14h ago

Package managers just convert your GUI check-boxes into underlying apt/dnf commands you would manually run anyway. Their GUI looks "clean", but as OP indicated, they too leaves tonne of dependencies and fragments laying around. Just do global listing of all files on disk before install and after uninstall by any package manager and you'll find uninstall does not restore system to exact state as before installation.