Tuesday 13 December 2011

Linux Command for Disk Space

$ du
Command to know the disk space of current directory and all subdirectory in kilo bytes

$ du -s
Summarizes the total size of directory

$ du -c
Prints the grand total of directories, recursively

$ du -a
Prints the size of every file and folder in the directory and subdirectory

$ du -h
Prints the size of directory in Human readable format, like 12M, 1.2G

$ du -h -c
Prints the grand total in human readable format

$ du / -c | sort -nr | head -n 10
Command to find top 10 directory having maximum disk space

$ du / -a | sort -nr | head -n 10
Command to find top 10 file and folders having maximum size

$ df -lk
Command to know the overall disk space usage of entire HDD