Posted On July 12, 2019

Linux: Reclaim Disk Space by Performing System Cleanups

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: Reclaim Disk Space by Performing System Cleanups
All systems:
Check disk space usage
# check /var directory
du -a /var | sort -nr | head -n 10

# check all directories, filter by large sizes
du -xh / |grep '^\S*[0-9\.]\+G'|sort -rn

# Find the top 20 big files
find / -printf '%s %p\n'| sort -nr | head -20

# Find anything over 100MB
find / -xdev -type f -size +100M -exec ls -la {} \; | sort -nk 5
Debian based systems
# Get rid of unused packages
sudo apt-get autoremove

# Clean apt-cache
sudo apt-get clean

# Clean thumbnail cache
rm -rf ~/.cache/thumbnails/*
Redhat based systems
# Install yum cleaner
yum -y install yum-utils

# Trim log files
find /var -name "*.log" \( \( -size +50M -mtime +7 \) -o -mtime +30 \) -exec truncate {} --size 0 \;

# Clean yum cache
yum clean all
rm -rf /var/tmp/yum-*

# Delete orphanated data from removed repos
rm -rf /var/cache/yum
package-cleanup --quiet --leaves --exclude-bin

# Remove composer cache
rm -rf /root/.composer/cache
rm -rf /home/*/.composer/cache

# Remove core dumps
find -regex ".*/core\.[0-9]+$" -delete

# Remove error logs
find /home/*/public_html/ -name error_log -delete

# If there's NodeJS, clean its cache
rm -rf /root/.npm /home/*/.npm /root/.node-gyp /home/*/.node-gyp /tmp/npm-*

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

How to Import Files Into a Docker Container

1. Use SCP to copy files to the remote server while logged onto the local…

Ubuntu Repos (Old Info)

Add this using the Software Center deb karmic free non-free   --------------------------- Add Many Repos…

Networking: Upgrading Legacy Ubiquiti Devices

Step 1: obtain the bin URL from https://www.ui.com/download/unifi/unifi-ap/uaplr Step 2: perform the upgrade rambo@kimlinux:/home/rambo# ssh…