4

I have $HOME on a separate partition so I can do a fresh distro install without disturbing my user data. This has worked fine over multiple installs.

However, over time I've noticed an accumulation of crud in dotfiles and dot-directories in $HOME - config and startup and history files from various programmes, some of which I haven't used in months, others that are no longer installed. And others I'd be concerned about importing old (now broken) config into the new versions of the programs in the latest distro...

Some are trivial - a single config file - but others are huge (.config or .thunderbird!) and complicated - do I want to cleanout some or all of that?

Any tips on going through these to avoid inheriting junk from old config, but without losing anything too precious?

ColinB
  • 523
  • "do I want to cleanout some or all of that?" - How is anyone else supposed to know if you don't? – xiota Jul 21 '19 at 19:57
  • 1
    Fair, but I suppose on reflection I was wondering whether there was a (semi-)automatic way of detecting which config files in ~/config had actually been modified and which had just been created when the program was first installed or used. So I use Calibre for reading books; ~/.config/calibre contains information about where my library is, what I've read. But I don't use enchant (a spellchecker) - there are files in there that are all default/vanilla/don't hold anything of value. Its just a pain to have to trawl through them all and work out whether I use them from the config file names! – ColinB Jul 24 '19 at 16:49

3 Answers3

1

Although ~/.config is large:

$ du -hs ~/.config
155M    /home/user_name/.config

You will probably find the largest is ~/.cache:

$ du -hs ~/.cache
1.4G    /home/user_name/.cache

You can delete ~/.cache when no applications are running and sections of it are rebuilt as need be. There are some caveats raised by other users though:

You definitely don't want to delete ~/.config which some users confuse with ~/.cache.

Caches exist in other places:

1

Any tips on going through these to avoid inheriting junk from old config, but without losing anything too precious?

You pretty much have to examine the files and folders yourself to determine whether they contain anything important to you. For instance, deleting .thunderbird will remove all saved emails.

  • You can use a cleaning program, such as bleachbit, to remove some unwanted files.

  • Tools that work with apt and dpkg, such as deborphan, clean up system config files that are created when packages are installed (in places like /etc and /var). They do not touch user home directories or config files that were created after installation.

  • .config was created as a place to put all those .* files without cluttering the home directory proper. Not everyone has followed the new convention, so there are still a lot of .* files in the home directory. You can look inside to decide what you want to keep or not. I advise against deleting it entirely because it's highly likely to contain files you'll want to keep.

  • .cache is usually safe to remove. Programs should recreate it as needed. Cleaner programs are usually able to manage this folder, so there's little need to bother with it directly.

  • You can remove empty files or folders with the find command:

    # remove empty folders
    find -depth -mindepth 1 -type d -empty -exec rmdir -v "{}" \;
    
    # remove empty files
    find -type f -empty -delete
    
  • You can start over with a clean user directory and move files over as-needed.

xiota
  • 4,849
-1

Any tips on going through these to avoid inheriting junk from old config, but without losing anything too precious?

This will list the packages that have left over configuration files:

deborphan --find-config

This will do the clean up:

deborphan --find-config | xargs dpkg --purge

(install with sudo apt install deborphan). If this shows a

dpkg: error: --purge needs at least one package name argument

there are no files found to purge.

do I want to cleanout some or all of that?

Your choice. It will do no harm not deleting them. And only save a few bytes. Clearing the cache will create more empty space though that might be temporary (cache will get rebuilt again).

Rinzwind
  • 299,756
  • Apt/dpkg tools don't touch user home directories. They affect config files in places like /etc. – xiota Jul 21 '19 at 20:06