CachyOS System Maintenance - ryzendew/Linux-Tips-and-Tricks GitHub Wiki

CachyOS System Maintenance Guide

Complete beginner-friendly guide to maintaining your CachyOS system, including updates, cleaning, optimization, and system health checks.


Table of Contents

  1. Understanding System Maintenance
  2. System Updates
  3. Package Management
  4. System Cleaning
  5. Disk Space Management
  6. System Health Checks
  7. Log Management
  8. Performance Monitoring

Understanding System Maintenance

What is System Maintenance?

System maintenance is keeping your system running smoothly and efficiently.

Why it matters:

  • Security: Updates fix security vulnerabilities
  • Performance: Cleaning improves performance
  • Stability: Maintenance prevents issues
  • Reliability: Well-maintained system is more reliable

Maintenance Tasks

Regular tasks:

  • Updates: Keep system and packages updated
  • Cleaning: Remove unnecessary files
  • Monitoring: Check system health
  • Optimization: Improve performance

Frequency:

  • Daily: Check for updates (optional)
  • Weekly: System updates, cleaning
  • Monthly: Deep cleaning, health checks

System Updates

Updating System

Update system (recommended method):

sudo pacman -Syu

What this does:

  • -S: Synchronize (install/update packages)
  • -y: Download fresh package database from servers
  • -u: Upgrade installed packages to newer versions

Important: Always use -Syu together. Using -Sy without -u can cause dependency issues.

What happens:

  • Downloads latest package information
  • Updates local package database
  • Upgrades all installed packages
  • Keeps system current

Update frequency:

  • Weekly: Recommended for most users
  • Before major changes: Always update first
  • After long time: Update before installing

Update Best Practices

Before updating:

  • Read announcements: Check for breaking changes
  • Backup: Backup important data
  • Close applications: Close running programs
  • Check disk space: Ensure enough space

During update:

  • Don't interrupt: Let update complete
  • Read output: Watch for errors
  • Don't power off: Wait for completion

After update:

  • Restart if needed: Some updates require reboot
  • Check system: Verify everything works
  • Test applications: Ensure apps still work

Handling Update Issues

Update conflicts:

# Check for conflicts
sudo pacman -Syu

# If conflicts found, resolve manually
sudo pacman -S package-name

Partial upgrades:

  • Avoid: Don't update individual packages
  • Always: Update entire system (-Syu)
  • Why: Prevents dependency issues

Failed updates:

# Clear package cache
sudo pacman -Sc

# Update again
sudo pacman -Syu

Package Management

Cleaning Package Cache

View cache size:

du -sh /var/cache/pacman/pkg

What this does:

  • Shows package cache size
  • Helps decide if cleaning needed

Clean old packages:

sudo pacman -Sc

What this does:

  • Removes old package versions
  • Keeps current versions
  • Frees disk space

Clean all cache:

sudo pacman -Scc

What this does:

  • Removes all cached packages
  • Warning: Will need to re-download packages
  • Use only if low on space

Removing Unused Packages

Find orphaned packages:

pacman -Qtdq

What this does:

  • Lists packages not needed by others
  • Shows orphaned packages
  • Can be safely removed

Remove orphaned packages:

sudo pacman -Rns $(pacman -Qtdq)

What this does:

  • Removes orphaned packages
  • -Rns: Remove with dependencies and configs
  • Frees disk space

** Review first:**

pacman -Qtdq

Check list before removing!

Package Database Maintenance

Check database integrity:

sudo pacman-db-upgrade

What this does:

  • Upgrades package database format
  • Fixes database issues
  • Ensures database is current

Rebuild package database:

sudo pacman-key --init
sudo pacman-key --populate archlinux

What this does:

  • Reinitializes package signing keys
  • Populates Arch Linux keys
  • Fixes keyring issues

System Cleaning

Cleaning Temporary Files

Clean /tmp:

sudo rm -rf /tmp/*

What this does:

  • Removes temporary files
  • Cleans /tmp directory
  • Frees space

** Warning**: Only if you're sure no programs are using /tmp

Clean user temp:

rm -rf ~/.cache/*

What this does:

  • Removes user cache files
  • Cleans application caches
  • Applications will rebuild caches

Cleaning Application Caches

Browser caches:

  • Clear in browser settings
  • Or delete cache directories:
    rm -rf ~/.cache/mozilla/*
    rm -rf ~/.cache/google-chrome/*
    

Package manager caches:

# pacman cache
sudo pacman -Sc

# AUR cache (if using yay)
yay -Sc

What this does:

  • Cleans package caches
  • Removes downloaded packages
  • Frees significant space

Cleaning Log Files

Check log size:

journalctl --disk-usage

What this does:

  • Shows journal log size
  • Helps decide if cleaning needed

Clean old logs:

sudo journalctl --vacuum-time=2weeks

What this does:

  • Removes logs older than 2 weeks
  • Keeps recent logs
  • Frees space

Limit log size:

sudo journalctl --vacuum-size=500M

What this does:

  • Limits logs to 500MB
  • Removes oldest logs
  • Maintains size limit

Cleaning Old Kernels

List installed kernels:

pacman -Q | grep linux

What this does:

  • Shows installed kernels
  • Helps identify old kernels

Remove old kernels:

sudo pacman -Rns linux-cachyos-5.19.1-1

What this does:

  • Removes specific kernel
  • Keep current and one backup
  • Frees space

** Keep at least 2 kernels!**


Disk Space Management

Checking Disk Usage

Check filesystem usage:

df -h

What this does:

  • Shows disk usage by filesystem
  • -h: Human-readable format
  • Shows used/available space

Find large directories:

du -h --max-depth=1 / | sort -hr

What this does:

  • Shows directory sizes
  • Sorted by size
  • Helps find large directories

Find large files:

find ~ -type f -size +100M -exec ls -lh {} \;

What this does:

  • Finds files larger than 100MB
  • Shows file sizes
  • Helps identify large files

Managing Disk Space

Remove large files:

  • Identify large files
  • Delete if not needed
  • Move to external storage

Move files to external storage:

mv ~/large-file /media/external/

What this does:

  • Moves file to external drive
  • Frees space on main drive
  • Keeps file accessible

Compress old files:

tar -czf archive.tar.gz old-files/

What this does:

  • Compresses files
  • Saves space
  • Keeps files accessible

Monitoring Disk Space

Set up monitoring:

# Check disk usage script
#!/bin/bash
df -h | awk '$5 > 80 {print "Warning: " $6 " is " $5 " full"}'

What this does:

  • Warns when disk > 80% full
  • Can be run regularly
  • Helps prevent full disk

System Health Checks

System Information

Check system info:

uname -a

What this does:

  • Shows kernel version
  • Shows system architecture
  • Shows system information

Check uptime:

uptime

What this does:

  • Shows system uptime
  • Shows load average
  • Shows system status

Check memory:

free -h

What this does:

  • Shows memory usage
  • Shows swap usage
  • Helps identify memory issues

Process Monitoring

Check running processes:

ps aux

What this does:

  • Lists all processes
  • Shows CPU/memory usage
  • Helps identify resource hogs

Check top processes:

top

What this does:

  • Shows top processes
  • Real-time updates
  • Shows resource usage

Alternative:

htop

What this does:

  • Better interface than top
  • More user-friendly
  • Install: sudo pacman -S htop

System Services

Check service status:

systemctl status

What this does:

  • Shows service status
  • Shows active services
  • Helps identify issues

Check failed services:

systemctl --failed

What this does:

  • Shows failed services
  • Helps identify problems
  • Can restart failed services

Restart failed service:

sudo systemctl restart service-name

Log Management

Viewing Logs

System logs:

journalctl

What this does:

  • Shows system logs
  • All log entries
  • Can be filtered

Recent logs:

journalctl -n 50

What this does:

  • Shows last 50 log entries
  • Recent system activity
  • Helps with troubleshooting

Service logs:

journalctl -u service-name

What this does:

  • Shows logs for specific service
  • Helps troubleshoot services
  • Service-specific information

Log Rotation

Systemd journal:

  • Automatically rotates logs
  • Configurable retention
  • Manages log size

Configure retention:

sudo nano /etc/systemd/journald.conf

Add:

SystemMaxUse=500M
MaxRetentionSec=2week

What this does:

  • Limits journal to 500MB
  • Keeps logs for 2 weeks
  • Prevents log bloat

Apply changes:

sudo systemctl restart systemd-journald

Performance Monitoring

CPU Monitoring

Check CPU usage:

top

Or:

htop

What this shows:

  • CPU usage per process
  • Overall CPU usage
  • Load average

Check CPU info:

lscpu

What this does:

  • Shows CPU information
  • Shows CPU features
  • Shows CPU architecture

Memory Monitoring

Check memory:

free -h

What this shows:

  • Total memory
  • Used memory
  • Available memory
  • Swap usage

Monitor memory:

watch -n 1 free -h

What this does:

  • Updates every second
  • Real-time memory monitoring
  • Helps track memory usage

Disk I/O Monitoring

Check disk I/O:

iostat -x 1

What this does:

  • Shows disk I/O statistics
  • Updates every second
  • Shows read/write speeds

Install iostat:

sudo pacman -S sysstat

Network Monitoring

Check network usage:

iftop

What this does:

  • Shows network usage
  • Real-time monitoring
  • Shows connections

Install iftop:

sudo pacman -S iftop

Check network stats:

ip -s link show

What this does:

  • Shows network statistics
  • Shows packets sent/received
  • Shows errors

Additional Resources


Summary

This guide covered:

  1. Understanding system maintenance - What it is and why it matters
  2. System updates - Keeping system updated
  3. Package management - Cleaning packages, removing unused
  4. System cleaning - Removing temporary files, caches
  5. Disk space management - Monitoring and managing disk space
  6. System health checks - Monitoring system status
  7. Log management - Viewing and managing logs
  8. Performance monitoring - Monitoring system performance

Key Takeaways:

  • Update system regularly (weekly recommended)
  • Clean package cache and temporary files
  • Remove unused packages and old kernels
  • Monitor disk space and system health
  • Check logs for issues
  • Monitor performance regularly
  • Keep at least 2 kernels installed
  • Backup before major maintenance

This guide is based on the CachyOS Wiki and Arch Linux Wiki and expanded with detailed explanations for beginners. For the most up-to-date maintenance information, always refer to the official documentation.