Fedora is known for its cutting-edge software, stability, and clean implementation of upstream technologies, but even it can accumulate digital clutter over time.
You might start with a 40 GB root partition feeling spacious, only to find it creeping toward 90% usage months later. The culprit isn’t a single large file but thousands of small, unnecessary pieces of data left behind by updates, installations, and normal system operations.
Fortunately, Fedora provides powerful command-line tools to reclaim that space quickly and safely. You don’t need third-party cleaner apps or GUI-based disk analyzers (though those have their place). With a handful of terminal commands, you can strip away the junk while keeping your system fully functional and stable.
Whether you are running Fedora Workstation on a laptop with a small SSD, hosting services on Fedora Server, or maintaining multiple machines, these 7 commands belong in your toolkit. Let’s open a terminal and start cleaning:
Clear the dnf cache
Remove stored package data safely
Start with:
sudo dnf clean all
Dnf keeps a local cache of downloaded packages and repository metadata in /var/cache/dnf. This speeds up installs and updates, but over time it builds up.
If you update frequently, this cache can easily reach hundreds of MBs or more and most of them are non-critical. Running this command removes everything in that cache. The next time you install or update packages, Fedora will simply download fresh copies.
There is a small trade-off in the form of a slightly slower next update but noticeably more free space now (a reasonable exchange unless you are on extremely limited bandwidth).
Remove orphaned packages
Clean unused dependencies automatically
Next:
sudo dnf autoremove
When you install software, DNF pulls in dependencies automatically: libraries, helper tools, runtime components. When you remove the original package, those dependencies often stay behind.
Over time, these accumulate into what are effectively unused packages. autoremove cleans them up. It removes only packages that are no longer required by anything else, so it is relatively safe.
If you want to preview what will be removed:
sudo dnf repoquery –unneeded
This gives you visibility before making changes. It is useful if you are cautious or just curious about what has been lingering in your system.
Trim system logs
Limit journal size effectively
System logs are useful, but they are not meant to grow indefinitely.
Run:
sudo journalctl –vacuum-size=200M
This limits your logs to 200 MB, deleting older entries automatically. Alternatively, you can keep logs by time:
sudo journalctl –vacuum-time=2d
This keeps only the last two days. Without this, logs can grow into GBs over time, especially on systems with frequent activity or debugging enabled.
Related
5 Great Linux Utilities to Monitor Your System Resources in the Terminal
Because the core utilities don’t do it all.
Empty the trash
Delete hidden recycled files permanently
If you delete files through a file manager, they are not actually deleted. They are moved to:
~/.local/share/Trash/
To clear it:
rm -rf ~/.local/share/Trash/*
This is safe for your user account, but it is permanent. There is no undo. It is also one of the easiest ways to reclaim space quickly, especially if you tend to “delete” large files without emptying the trash afterward (which is more common than most people admit).
Clean /var/tmp
Remove persistent temporary system files
Fedora uses two temporary directories: /tmp/ and /var/tmp. The /tmp directory is designed for short-lived temporary files that don’t need to survive a system restart. Most Fedora configurations clear /tmp automatically during boot, either fully or by removing files older than a certain age, making it ideal for session-specific data like browser caches or application scratch space.
Whereas, /var/tmp preserves its contents across reboots, serving as a location for temporary files that need to persist longer, such as interrupted download fragments, package manager leftovers from incomplete installations, or long-running process data that should survive a system crash or intentional reboot.
The second one is where things quietly pile up. Clean it with:
sudo rm -rf /var/tmp/*
This removes leftover temporary files from installers, scripts, and processes that never cleaned up after themselves. It is generally safe, but avoid running it while major installations or updates are in progress (timing matters here).
Clear old user cache files
Remove stale cache data safely
User-level caches can become surprisingly large. Browsers, package managers, and desktop environments all store data in:
~/.cache
Instead of deleting everything blindly, remove only older, unused files:
find ~/.cache -type f -atime +30 -delete
This deletes files not accessed in the last 30 days. It is a balanced approach as you keep active cache files for performance, while removing stale ones that serve no purpose.
Related
ShredOS: How to Securely Wipe a Hard Drive With Linux
Getting rid of your old PC? Make sure you wipe it clean to protect yourself.
Remove old kernels
Free space but proceed carefully
Fedora keeps multiple kernel versions as a safety measure. If a new kernel fails, you can boot into an older one. That is a good default, but each kernel takes space. Typically, 200 to 400 MB once you include modules and initramfs.
To clean up old kernels:
sudo package-cleanup –oldkernels –count=2
This keeps the current kernel and one previous version, removing everything else. If the command is missing:
sudo dnf install yum-utils
Do not manually delete files from /boot. Kernel management is one of those areas where precision matters more than confidence (and guessing wrong has consequences). I won’t suggest using it on something critical unless you are quite sure about it.
What you should not touch
Avoid breaking critical system areas
Some directories look like cleanup targets but are not.
Avoid these:
/boot manually
~/.config
/var/log directly
These contain critical data, settings, or active logs. Removing files blindly here can break things in subtle or obvious ways. Always use the appropriate tools instead of manual deletion.
How often should you do this
Set a simple maintenance routine
There is no strict schedule, but a good rule is to clean up after major updates or once every few weeks, especially when disk space starts shrinking unexpectedly.
Related
10 Things You Should Do Right After Installing Fedora Linux
10 tricks to supercharge your new Fedora installation!
Fedora does not require constant maintenance as it is designed to be stable and self-managing for the most part, but no system can automatically remove every stray log file, orphaned dependency, or old kernel that lingers after months of use.
What actually changes after cleanup
After running these commands, the changes are not dramatic in appearance. In fact, there is no clear visual change. What you get instead is more free disk space, cleaner package state, smaller logs and fewer leftover files. The system feels lighter because unnecessary weight has been removed without installing any additional tools.

