Skip to content

Instantly share code, notes, and snippets.

@viniciusgonmelo
Last active July 3, 2023 21:35
Show Gist options
  • Save viniciusgonmelo/db5839661e8af9c392b54bd2d0181a84 to your computer and use it in GitHub Desktop.
Save viniciusgonmelo/db5839661e8af9c392b54bd2d0181a84 to your computer and use it in GitHub Desktop.
Comandos para liberar espaço na partição root do Debian.
#!/usr/bin/env bash
# Libera espaço da partição root no Debian
# Executar os comandos como root
if [ "$EUID" -ne 0 ]
then echo "Executar como root"
exit
fi
# Limpa o repositório local
apt autoclean
# Remove pacotes orfãos e os arquivos de configuração
apt autoremove --purge
# Limpa arquivos temporários
find /tmp -type f -delete
# Remove logs antigos
journalctl --rotate
journalctl --vacuum-time=7d
# Remove kernels antigos
dpkg --list \
| grep linux-image \
| awk '{ print $2 }' \
| sort -V \
| sed -n '/'"$(uname -r)"'/q;p' \
| xargs sudo apt-get -y purge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment