Linux-equivalent to CCleaner: Cleaning up disk space
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Linux-equivalent to CCleaner: Cleaning up disk space
I know of many (but not all) these locations where files can be found that can/should be deleted to clear disk space. On Windows I use CCleaner, which does a decent job. Windows also has a built-in cleaner facility in Disk Management.
1) Is there a safe Linux-equivalent to CCleaner or that Disk Management tool?
2) Alternatively, I want to write a script that goes through the usual
suspect locations for clean-up. Someone has a script like that?
3) To that end, what are the usual suspect locations to concentrate on?
Distribution: Ubuntu based stuff for the most part
Posts: 1,173
Rep:
I have not used CCleaner, but some of these tools might help you:
apt search diskspace
Sorting... Done
Full Text Search... Done
filelight/jammy,jammy 4:22.04.3-0ubuntu1~ubuntu22.04~ppa1 amd64
show where your diskspace is being used
gdmap/jammy,jammy,jammy,jammy 0.8.1-5build1 amd64
Tool to visualize diskspace
libfilesys-diskspace-perl/jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy 0.05-16+nmu2.1 all
fetch filesystem size and usage information from Perl
Some people like to clear their package manager cache regularly, others might want to prune browser downloads, others might want to limit how long logs are kept for, and so on.
Best to use Filelight (or similar) to identify large pockets of data, then ask "what is this? do I want it?".
You can read the Filesystem Hierarchy Standard to get an approximate idea of what various directories might contain - but it's not authoritative / strictly adhered - it's more of an approximate guide than a standard.
Ultimately, if you're low on disk space, it may be simpler to buy a bigger disk, rather than waste time trying to clear every bit of unwanted data.
As above, what 'you' want to keep or not, is specific to 'your' situation.
Typically looking under /var/log is a good place to start, but for 'business' systems, there may be legal or business requirements to keep X amount of files online or at least archived in an easily retrievable place. (for example).
This is why logrotate exists, to automatically handle this for you. Note that logrotate is a generic tool, it doesn't only handle that dir, it can tidy any dir you want.
On my personal laptop, I always use
Code:
dnf clean all
before updates.
Helps tidy stuff up and ensures that the meta file data used for the repos is always the latest.
Really, it's mainly the latter; they don't take up that much disk space.
The likes of Fatdog use a sfs (squashed filesystem) as the main system. With that you can boot, configure things as you like, and then create a new version. Thereafter ... you boot that exact same 'clean' (fresh/new) configured system every time. Don't store any data files in that, save them elsewhere and its like booting a brand new session every time. For browser bookmarks, just store them elsewhere, I've set up a alt-spacebar key combination that presents my common bookmarks, so can alt-space and arrow keys (or mouse click) to a particular bookmark and have the browser launch that URL.
A nice feature is that if you screw up the system during a session then you just reboot. But you do have the bother of booting, making desired changes and forming a new sfs for any changes that you do want to have preserved. Typically you'll do that a lot at first, but decreases to rare/infrequent later.
And of course any hacks that may otherwise get to persist long term, hidden away somewhere within your system, are just zapped after a reboot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.