Hidden Linux : Example commands - df and du
The Linux command line is immensely powerful, especially if you combine
it with handy popup access from an application like Yakuake,
but sometimes you just want to know what string to type without having
to wade through screens of man
pages. That's what this occasional series is about.(As always, you can type man <command_name> for full details about a command.)
df - Disk free space
Show disk usage and free space:
df
Show disk usage and free space in "human-readable" format (like 1K, 10M, 4.2G):
df -h
Show disk usage and free space in "human-readable" format but using powers of 1,000, not 1,024 (just like disk drive manufacturers do when quoting the sizes of their drives!):
df -H
du - Disk usage
Show file space usage in the current directory:
du
Show file space usage in the current directory in "human-readable" format:
du -h
Show file space usage in your home directory:
du -h ~
Sort usage to display the largest files last:
du -h | sort -n
Summarise the current directory's usage:
du -sh
Summarize usage by all level 1 sub-directories (not sub-sub-directories, etc.):
du -sh *
Show the file space used in /usr/share/icons:
du -sh /usr/share/icons/
Summarise the file space used by all sub-directories in /usr/share/icons:
du -sh /usr/share/icons/*
Show the size of all sub-directories in your home folder:
du -sh ~/*
Any more useful ones? Leave a comment!
![]() |
![]() |



PC World is New Zealand’s top selling computing and technology magazine.
Comments
Using the period/full stop is also useful with 'df'. For example 'df -h .' displays disk usage and free space only on the current partition.
Posted by: Adrian | February 11, 2010 1:49 PM