gin
js
===
rubymine
+
+
+
docker
+
elixir
numpy
+
axum
spacy
zig
+
+
+
+
+
+
cassandra
htmx
pascal
โˆš
intellij
vercel
istio
+
elementary
scala
nuxt
lit
next
+
+
@
+
+
+
xml
+
+
htmx
+
+
htmx
&
css
c
pip
terraform
+
+
<=
+
mint
+
yaml
+
neo4j
apex
+
+
+
//
grafana
parcel
=>
+
=
+
debian
โˆ‚
+
+
+
+
+
ts
+
+
+
alpine
bun
windows
+
hapi
!==
+
Back to Blog
๐Ÿ’พ Disk Space Management and Cleanup Strategies in AlmaLinux: Simple Guide
AlmaLinux Disk Space System Maintenance

๐Ÿ’พ Disk Space Management and Cleanup Strategies in AlmaLinux: Simple Guide

Published Aug 19, 2025

Learn how to check disk space, find large files, and clean up your AlmaLinux system. Perfect for beginners with easy commands and practical examples to free up storage space.

8 min read
0 views
Table of Contents

๐Ÿ’พ Disk Space Management and Cleanup Strategies in AlmaLinux: Simple Guide

Is your AlmaLinux system running out of space? Donโ€™t worry! ๐Ÿ˜Š Weโ€™ll learn how to check disk usage, find whatโ€™s eating up your storage, and clean things up safely. Itโ€™s easier than you think! Letโ€™s make your system breathe again! ๐Ÿš€

๐Ÿค” Why is Disk Space Management Important?

Managing disk space keeps your computer happy and healthy! Hereโ€™s why it matters:

  • ๐Ÿ’จ Better Performance - More free space means faster system
  • ๐Ÿ›ก๏ธ Prevents Crashes - Full disks can cause system failures
  • ๐Ÿ“ฆ Install New Software - Need space for updates and programs
  • ๐Ÿ“Š Smooth Operations - Services need room to work properly
  • ๐Ÿ”„ Backup Space - Room for important file backups
  • ๐Ÿ“ Log Files - System needs space to write logs

๐ŸŽฏ What You Need

Before we start cleaning, make sure you have:

  • โœ… AlmaLinux system (any version)
  • โœ… Terminal access
  • โœ… Basic command line knowledge
  • โœ… Admin (sudo) access for some commands
  • โœ… 5-10 minutes to follow along

๐Ÿ“ Step 1: Check Your Disk Space

Letโ€™s see how much space you have left! ๐Ÿ”

Check All Disks

# Show disk usage in human-readable format
df -h

Example output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G   12G  7.0G  64% /
/dev/sda2       100G   45G   50G  48% /home
tmpfs           2.0G     0  2.0G   0% /dev/shm

What this shows: ๐Ÿ“–

  • Size = Total disk size
  • Used = Space already used
  • Avail = Free space available
  • Use% = Percentage used (watch this!)
  • Mounted on = Where disk is connected

Check Specific Directory

# Check home directory size
du -sh /home

# Check with more detail
du -h /home --max-depth=1

๐Ÿ”ง Step 2: Find Whatโ€™s Using Space

Time to find the space hogs! ๐Ÿท

Find Large Files

# Find files larger than 100MB
find / -type f -size +100M 2>/dev/null

# Find top 10 largest files
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10

Check Directory Sizes

# See sizes of directories in current location
du -h --max-depth=1 | sort -rh

# Check /var directory (common space user)
sudo du -h /var --max-depth=1 | sort -rh

Pro tip: ๐Ÿ’ก The /var directory often fills up with logs and cache!

๐ŸŒŸ Step 3: Clean Package Cache

Package managers save downloaded files. Letโ€™s clean them! ๐Ÿงน

Clean DNF Cache

# Check cache size first
sudo du -sh /var/cache/dnf

# Clean all cached packages
sudo dnf clean all

# Remove old packages only
sudo dnf clean packages

Remove Old Kernels

# List installed kernels
rpm -qa kernel

# Keep only 2 newest kernels
sudo dnf remove --oldinstallonly --setopt installonly_limit=2 kernel

What happens: ๐Ÿ”„

  • Old package files are deleted
  • Downloaded metadata is cleared
  • Old kernels are removed
  • You free up lots of space!

โœ… Step 4: Clean Log Files

Logs can grow huge! Letโ€™s manage them properly. ๐Ÿ“š

Check Log Sizes

# See log directory size
sudo du -sh /var/log

# Find large log files
sudo find /var/log -type f -size +100M

Clean Old Logs

# Clear systemd journal logs older than 7 days
sudo journalctl --vacuum-time=7d

# Or keep only 500MB of logs
sudo journalctl --vacuum-size=500M

# Clear specific log file safely
sudo truncate -s 0 /var/log/messages

Setup Automatic Cleanup

# Configure journal size limit
sudo nano /etc/systemd/journald.conf

# Add these lines:
SystemMaxUse=500M
SystemMaxFileSize=100M

๐ŸŽฎ Quick Examples

Example 1: Quick Cleanup Script ๐Ÿš€

#!/bin/bash
# Save as cleanup.sh

echo "๐Ÿงน Starting cleanup..."

# Clean package cache
sudo dnf clean all

# Clean journal logs
sudo journalctl --vacuum-time=7d

# Empty trash
rm -rf ~/.local/share/Trash/*

echo "โœ… Cleanup complete!"

# Check free space
df -h /

Example 2: Find and Delete Old Files ๐Ÿ“…

# Find files not accessed in 30 days
find ~/Downloads -atime +30 -type f

# Delete them (careful!)
find ~/Downloads -atime +30 -type f -delete

# Find and remove .tmp files
find /tmp -name "*.tmp" -mtime +7 -delete

Example 3: Emergency Space Recovery ๐Ÿ†˜

# When disk is critically full

# 1. Clean package cache immediately
sudo dnf clean all

# 2. Clear all journal logs
sudo journalctl --vacuum-time=1d

# 3. Empty /tmp
sudo rm -rf /tmp/*

# 4. Check space recovered
df -h

๐Ÿšจ Fix Common Problems

Problem 1: โ€œNo space left on deviceโ€ โŒ

Symptoms:

  • Canโ€™t save files
  • Canโ€™t install updates
  • System acting weird

Try this:

# Emergency cleanup
sudo dnf clean all
sudo journalctl --vacuum-time=1d
sudo rm -rf /var/tmp/*

# Find largest files
sudo du -ahx / | sort -rh | head -20

Problem 2: Root partition full โŒ

Try this:

# Check what's using root space
sudo du -hx --max-depth=1 /

# Common culprits
sudo du -sh /var/log
sudo du -sh /var/cache
sudo du -sh /tmp

Problem 3: Canโ€™t find whatโ€™s using space โŒ

Check these hidden spots:

# Check for deleted but open files
sudo lsof | grep deleted

# Check docker if installed
docker system prune -a

# Check snap packages
du -sh /var/lib/snapd

๐Ÿ“‹ Simple Commands Summary

TaskCommand
๐Ÿ‘€ Check disk spacedf -h
๐Ÿ“Š Check directory sizedu -sh /path
๐Ÿ” Find large filesfind / -size +100M
๐Ÿงน Clean package cachesudo dnf clean all
๐Ÿ“ Clean logssudo journalctl --vacuum-time=7d
๐Ÿ—‘๏ธ Empty trashrm -rf ~/.local/share/Trash/*
๐Ÿ’พ Check top disk users`du -h / โ€”max-depth=1

๐Ÿ’ก Tips for Success

  1. Regular Cleaning ๐Ÿ”„ - Clean monthly to prevent buildup
  2. Monitor Usage ๐Ÿ“Š - Check disk space weekly
  3. Set Limits ๐Ÿ“ - Configure log rotation and limits
  4. Before Deleting โš ๏ธ - Always check what youโ€™re removing
  5. Keep Backups ๐Ÿ’พ - Save important files before cleanup

๐Ÿ† What You Learned

Great job! Now you can:

  • โœ… Check disk space usage
  • โœ… Find large files and directories
  • โœ… Clean package cache safely
  • โœ… Manage log files properly
  • โœ… Create cleanup scripts
  • โœ… Recover from full disk situations

๐ŸŽฏ Why This Matters

Now your AlmaLinux system:

  • ๐Ÿš€ Runs faster with more free space
  • ๐Ÿ›ก๏ธ Wonโ€™t crash from full disks
  • ๐Ÿ“ฆ Has room for new software
  • ๐Ÿ”„ Updates smoothly
  • ๐Ÿ“Š Operates more efficiently

Remember: A clean system is a happy system! Regular maintenance prevents big problems! โญ

Keep your disk clean and your AlmaLinux will thank you! Happy cleaning! ๐Ÿงนโœจ