Tuesday, 16 August 2011

Checking disk space in linux

If the disk space is full and you need to clear out the unwanted files and directories, the following commands can be used to find out where exactly the space is being used.

First check the disk space using:

fdisk -l

Then check the mount points using

mount

after that check the directory usage using

cd /

du -hs * or du -ks *


Then clear out the files accordingly.

Also we can use the following command to find out the large files:

The following command works with redhat distros'

find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

you need to change the awk command accordingly on ubuntu/debian or other distros.

No comments:

Post a Comment