How to Safely Delete Junk Files in EndeavourOS (Arch Linux)
As time goes by, operating systems like EndeavorOS (an Arch Linux derivative) will store various temporary files, old package caches, system logs, and packages that are no longer needed. If left alone, these files can take up quite a lot of disk space.
For Linux users like me who use SSDs with small storage capacity (120GB), you need to pay attention to storage that is getting thinner over time. If not monitored and cleaned regularly, it will take up even more storage, apart from files that can be seen.
So there are several ways to clean it.
Safe and Controlled guide to cleaning junk files without damaging the system
1. Delete old package caches (leaving only the last 3 versions)
When the user installs a package, the system will save its cache. Actually, this is useful for example if there is an error we can downgrade to the previous version without having to re-download the package that was installed. But sometimes this actually takes up a lot of disk space if left alone. So it needs to be cleaned with this step:
sudo pacman -S pacman-contrib Install the paccache tool if it is not already
sudo paccache -r Delete the old version cache, leaving the 3 latest versions
If you want to leave only 1 latest version:
sudo paccache -rk1
2. Remove Orphaned Packages (No Longer Used)
Orphaned packages is packages that were previously installed as dependencies, but this package are now not needed by any application. To remove this package, you can type this in the terminal:
sudo pacman -Rns $(pacman -Qtdq)
What happens? This will remove unused dependencies, and does not interfere with the main application.
3. Reduce the Size of the System Log
The system log can swell to hundreds of MB. We can delete logs that are too old.
Use the command below to check the total size of system logs:
journalctl --disk-usage
And users can reduce the size eaten by this system log. To delete Endeavour OS logs older than 7 days:
sudo journalctl --vacuum-time=7d
The command will save the last 7 days of logs, so only delete those that are past 7 days. Adjust to your needs, so it doesn't have to be 7 days, you can change it longer, for example 14 days.
4. Clearing the cache of unused packages
To clear the cache of unused packages in Endeavour OS, users can use the command below:
sudo pacman -Sc
I do not recommend using -Scc because it will delete all caches including packages that are still needed, just use -Sc to save disk space without the risk of losing important caches.
Those are some of the ways I use to save space or reduce junk files in Endeavour OS. Hopefully useful