This post builds on our prior "Recovering Space" post, which can be found (here).
Here is how to clear the deb cache (container packages of installed or upgraded apps) and delete everything from /var/cache/apt/archives/ where they are kept.
The sudo apt clean
or sudo apt-get clean
command clears the /var/cache/apt/archives/ directory of retrieved package files, except for the lock file.
OR
sudo apt-get autoclean
Like clean, autoclean clears out the local repository of retrieved package files. but only of the package files that can no longer be downloaded. This lets you keep packages to roll back to, or otherwise use offline.
Your system (largely the file managers) creates and stores thumbnail (small-sized) versions of photos, album covers and other images.
These thumbnails greatly speed up opening the file managers, but as you can imagine, the number, and total file size of these thumbnails can accumulate quickly.
The folder that these are stored in ~/.cache/thumbnails and you can safely remove them to save space. The thumbnails will be recreated, as needed.
As you may guess, start with /large. The most disk space will be used by this thumbnail subfolder.
To use jdupes:
For example:
jdupes -S -r /m/b/C* /m/b/O*
852882 bytes each:
./IMG_20110310_205619.jpg
./NIKON-Pictures (back-up)/DCIM/Camera/IMG_20110310_205619.jpg
./NIKON-Pictures (back-up)/2015/backups/IMG_20110310_205619.jpg
3243133 bytes each:
./2024/06/IMG_20240612_125030915.jpg
./2024/Moto Photos/IMG_20240612_125030915.jpg
3797570 bytes each:
./2024/09/IMG_20240326_190436955_HDR.jpg
./2024/Moto Photos/IMG_20240326_190436955_HDR.jpg
Finally, pick the files from those shown to delete using rm.
Sadly, while you can sort by modified date or filename, jdupes does not let you sort by Size. We will add sorting to jdupes in an upcoming post. (edit. see: jdupes.sh)
systemd can store GBs of past binary journal entries in /var/log/journal/. These files are used by admins to figure out system issues. You generally only need to keep the most recent ones around. The rest can be removed.
To see how much space these journal files are currently using, run:
To cut down the number of journal files, run these steps.
You can vary the number and the length-of-time of files to keep. e.g. 2w saves 2 weeks worth of journal files, or 2d (2 days) worth, or 30m (30 minutes) worth.
Going forward, you can alter systemd's journal configuration to automatically keep a smaller number of journal files.
To do so: Make a backup of the journal config and edit the file.
sudo nano /etc/systemd/journald.conf
Uncomment (remove the '#') from one of these two settings. We recommend SystemMaxUse=500M to always retain the most recent 500MB of journal entries.
[Journal] Setting DescriptionSave the config file and restart journaling to reload the changed config:
sudo sed -i 's/#SystemMaxUse=100M/SystemMaxUse=500M/g' /etc/systemd/journald.conf
For more info on journal files, see https://linuxhandbook.com/clear-systemd-journal-logs/.
If you are working with a large hard drive, this one will probably get back the most space of anything in this article.
By default, Linux drives use the EXT file system. Also by default, EXT reserves 5% of the disk space to itself. This was done to give administrators some room to work if a system ran out of space. The amount 5% was chosen back when hard drives were very small but today, with TB-size drives, 5% represents a large chunk of space. For example, 5% of a 5TB drive is around 250GB.
BEFORE tune2fsFirst, get the list of partitions:
df -h
Next, use tune2fs with grep to see if blocks are reserved on your EXT drives.
Replace /dev/sdb2 below with your device.
sudo tune2fs -l /dev/sdb2 | grep 'Reserved'
Reserved block count: 0
Reserved GDT blocks: 1024
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
Finally, run tun2fs and set the number of reserved blocks to 0.
sudo tune2fs -m 0 /dev/sdb2
See also, Recovering Space Recovering Space, Part 2 (this file) Recovering Space, Part 3: jdupes.sh