Skip to content

Instantly share code, notes, and snippets.

@opabravo
Last active February 23, 2025 07:36
Show Gist options
  • Save opabravo/ed9413fdbb29e837089a29cc8ed052b5 to your computer and use it in GitHub Desktop.
Save opabravo/ed9413fdbb29e837089a29cc8ed052b5 to your computer and use it in GitHub Desktop.
CheatSheet to Check and clear space on linux
df -h
du -sch /* 2>/dev/null

# Install ncdu to check space usage
apt install ncdu -y
ncdu /

# clear compressed logs
find /var/log/ -type f -name "*.gz" -delete

# Clear uninstalled packakges leftovers
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge

# Clear apt packages' cache
apt clean && apt autoremove
sudo du -sh /var/cache/apt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment