Cleaning up Unix disk space

From time to time you may need to clean up your system as disk space runs low. Realistically you should look at setting up syslog to handle areas of your disk that might be prone to blowout usage but if you haven’t then the following commands may be of use.

The command below will show you how much space you have on your disks
df -h

The command below will help you narrow down where the offending directories are
du -xh --max-depth=1  /
then drilldown to find deeper eg
du -xh --max-depth=1  /var/

Now you might enter a directory and try to ‘rm *’ all the files in there. If there are too many files in there you will get this error
/bin/rm: Argument list too long

Solution is to enter the directory

cd /tmp/theOffendingDirectory
find . -name '*' | xargs rm

Maybe it is logfile that you just want to truncate to zero which you can do with the command
truncate -s 0 /tmp/warnings.log
I recommend shutting down syslog if it is a syslog file then restarting after truncation.

Tags: , , , , ,

Leave a Reply