URI: 
       Title: Spring cleaning your Debian system
       Author: cyr4x3
       Date: 17 November 2022
       Tags: linux
       ============
        
       # Introduction
        
       I like to think of computers comparing them to houses. Buying new things for
       your house or upgrading the things you already own may seem the most
       straight-forward way to make your house a better place. Buying new furniture
       can help your house look more modern, prettier and improve your overall quality
       of life. Replacing old tools and household appliances for new ones may help you
       accomplish some tasks in a more efficient way. You get the idea. The same can
       be said about computers if we replace the terms 'furniture' and 'household
       appliances' for 'software' and/or 'hardware'.
        
       My point here is that, while of course a modern and new house can be really
       convenient and desirable, a clean and well-organized house should be a
       priority. It doesn't matter how new and cool your house is and how many gadgets
       and fancy items you have in it if it isn't clean and organized. The same
       happens with computers. For me, having a lot of tools or software installed and
       readily available but not even using half of it or keeping software you don't
       use anymore, cluttering your system with no real purpose at all, is the
       equivalent of having a messy house with old stuff you'll never touch again and
       with random items spread everywhere.
        
       As with houses, with computers there's a time of the year when one should
       really spend some time cleaning the mess that daily usage comes with. I'm not
       talking only about removing old files and programs we no longer use, but also
       removing the clutter that things like our package manager may've left behind
       when performing tasks such as a version update (or dist-upgrade).
        
       Although this article is mainly focused on Debian (and Debian-based
       distributions) I'm sure you can find tools and commands that can be equivalent
       to any other Linux distribution.
        
        
       # Where should we start?
        
       In the same way that happens when you're spring cleaning your house, when
       you're spring cleaning your computer you will regret not having the habit of
       doing it regularly, as it'd require much less work. So my first tip would be to
       have the habit of keeping your system clean, with only the things you need.
        
       In the next few sections I'll go over some of the commands you may want to use
       for cleaning up your Debian system. You can go through all of them when you
       feel like it, as there's no wrong time for cleaning up your computer. However
       and as I said before, doing so before and after you perform a dist-upgrade
       (or a big upgrade in general) is highly recommended.
        
       Before we start, I advise you to read carefully through the output of every
       command you type in the terminal, don't just answer yes to every prompt and
       don't blindly believe me on everything. Read the warnings and understand every
       command you type before confirming any action. I'm not responsible for the
       damage that your actions may cause to your machine(s).
        
        
       # First sweep through
        
       The first and more basic thing one can think of when cleaning up a system is
       removing unused stuff, whether it is personal files or packages. If you want to
       free up some space in your computer and you have a ton of movies, TV series,
       games and music in your hard drive (legally downloaded, ofc ;) ) that you've
       already played and watched, that may be the first thing you need to check. For
       this task du and/or ncdu (a ncurses interface for du) may come in handy.
       They'll show you how much space are your files taking up, so you can choose
       whether to remove them or not.
        
       If you're not a really organized person you may also have duplicated files in
       your computer. Maybe, when downloading stuff from the internet, you download
       the same document several times and forget to delete the duplicates, for
       example. In that case, please stop. But how do you clean the mess that you
       already have? Well, czkawka has got you covered. This program is, as
       described in its GitHub page, "a simple, fast and free app to remove
       unnecessary files from your computer". It has a CLI version as well as a GUI
       one, which are quite intuitive. You may want to add this program to your set of
       tools for spring cleaning.
        
  HTML Czkawka (GitHub)
        
       Okay, enough talk about personal files, what about system packages? The same
       logic applies. I recommend deleting everything you don't need and/or don't plan
       to use ever again. Ask yourself these questions: do I really need having all
       these desktop environments and/or window managers when I always log in to the
       same one? Do I really need all these pieces of software that I once installed
       to play around with and never used ever again? I'm not saying you should
       uninstall everything you don't use on a daily basis, as you may want to keep
       some stuff that may come in handy when the time comes, but knowing what you
       have installed and why it is installed is always a good thing.
        
       There are different approaches for tackling this problem. The first one, and
       the one that makes more sense if you're desperate to free up some space, would
       be to have a list of all the packages currently installed (through apt) and
       sort them by the space they're taking up. Once you have this list, you can
       start deleting packages you no longer need, starting with the big ones. This
       list can be obtained with this simple command:
        
        
           $ dpkg-query -Wf '${Installed-Size} ${Package}\n' | sort -rn
        
        
       Another simple and clean option is using a Perl script called ds, written by
       Greg Wooledge, that does basically the same thing as the command shown above
       with the main difference that it won't list anything that's in state
       "deinstall" ("rc" on dpkg -l).
        
  HTML ds script
        
  HTML Greg's Domain
        
        
       # Remove all that clutter
        
       The easiest thing we can do to remove the clutter that the apt package manager
       may've stored in our hard drives, is the following:
        
        
           $ sudo apt autoremove --purge && sudo apt-get clean && sudo apt-get autoclean
        
        
       The autoremove option is used to remove packages that were automatically
       installed to satisfy dependencies of a package that has since then been removed
envs.net:70 /~cyr4x3/article-spring-cleaning-your-debian-system:124: invalid line / field count