Troubleshooting Disk Space Usage

October 16, 2017 0 Comments ubuntu

A couple years ago, my coworker wrote a great post on finding disk space issues in Linux and how to resolve them. Helped me out this weekend when a critical server was having issues, so wanted to post it here:

For future reference (after reading the post above)

Show filesystem usage:

~$ df -h

Show files/directories consuming space:

~$ du -kx / | sort -nr | more

List files in directory:

~$ ls -larth

List and then delete any .log file older than 7 days:

~$ find . -type f -name "*.log" -mtime +7 -print -exec rm -fr {} \;

Another easy way to reclaim space by removing unused dependencies:

~$ apt-get autoremove