Maintenance
Regular maintenance includes updating software, backing up data, cleaning orphaned packages and caches, and installing LTS kernels to keep Linux secure, efficient, and stable.
Step 1:Updates
Updating your system is one of the most important things you can do. Updates include security patches, bug fixes, and improvements. Linux won’t force updates on you, so it’s good practice to check and update at least once a week. Keeping packages up to date protects you from vulnerabilities and helps keep your system stable.
Commands to update your system:
Arch
sudo pacman -Syu
Debian
sudo apt update && sudo apt upgrade
Fedora
sudo dnf upgrade
Step 2: Cleanup Orphaned packages:
Orphaned packages are leftover dependencies installed for software you no longer have. They just take up space and clutter your system. Removing them helps free disk space and keeps your system tidy.
Commands to clean orphaned packages:
Arch
sudo pacman -Rns $(pacman -Qdtq)
Debian
sudo apt autoremove
Fedora
sudo dnf autoremove
Step 3: Trim Your SSD
SSDs work differently than traditional hard drives. They need to be told which blocks of data are no longer in use to maintain speed and longevity. This process is called trimming.
You can enable automatic weekly trimming so you don’t have to think about it, or run it manually if you prefer.
Enable periodic trimming:
sudo systemctl enable --now fstrim.timer
Once enabled, it runs every week and trims the SSD automatically.
Run trim manually:
sudo fstrim --all
Step 4: Check Logs
When something’s wrong or you just want to make sure everything’s okay, check your system logs. Logs record everything from errors to warnings and important events. It’s a great habit to glance at logs regularly to catch potential issues early.
View all logs since last boot:
journalctl -b
View error messages only:
journalctl -p err -b
Step 7: Clean cache
Package manager cache is where Linux stores downloaded installer files (packages) locally so it can reuse them later. It helps speed up installs and saves bandwidth, but over time it can take up a lot of disk space. Cleaning the cache frees up space.
Arch
sudo pacman -Scc
Debian
sudo apt autoclean
Fedora
sudo dnf clean all
Step 9: Make sure you have enough space
Make sure your system has enough free space to function properly. Sometimes hidden files or directories take up a lot of space without you realizing it.
sudo du -x -h -d1 /
The above command will list all the folders inside the root directory along with how much space they take.
Last updated