Linux disk usage statistics

The following are some useful commands to figure out which directory is consuming all of your disk space.

You can use the df command to find your disk free space for your mounted filesystems, for example :-

Show Plain Text
Text code
  1. # df -h -T
  2. Filesystem    Type    Size  Used Avail Use% Mounted on
  3. /dev/sda1     ext3     57G   15G   39G  28% /
  4. tmpfs        tmpfs    1.9G     0  1.9G   0% /lib/init/rw
  5. udev         tmpfs     10M   52K   10M   1% /dev
  6. tmpfs        tmpfs    1.9G     0  1.9G   0% /dev/shm
  7.  

The du cammand can be used to give your disk usage information, for example :-

Show Plain Text
Text code
  1. # ls | du -ch
  2. 52K     ./mysql
  3. 4.0K    ./bittorrent
  4. 20K     ./apt
  5. 136K    ./ntpstats
  6. 4.0K    ./samba/cores/smbd
  7. 4.0K    ./samba/cores/nmbd
  8. 12K     ./samba/cores
  9. 4.9M    ./samba
  10. 4.0K    ./iptraf
  11. 540K    ./apache2
  12. 12K     ./fsck
  13. 56K     ./exim4
  14. 4.0K    ./news
  15. 9.2M    ./installer/cdebconf
  16. 9.8M    ./installer
  17. 21M     .
  18. 21M     total
Filed under: Linux  Tags: Debian, Ubuntu

1 Responses to “Linux disk usage statistics”

It is usefull du -k |sort -nr

Sorry, comments have been closed for this post.
(default) 11 queries took 4 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `posts`17171
2DESCRIBE `comments`11111
3DESCRIBE `tags`221
4DESCRIBE `categories`221
5DESCRIBE `posts_tags`220
6DESCRIBE `categories_posts`220
7SELECT `Post`.`id`, `Post`.`url`, `Post`.`title`, `Post`.`icon`, `Post`.`metadesc`, `Post`.`metakeys`, `Post`.`categories`, `Post`.`tease`, `Post`.`body`, `Post`.`private_body`, `Post`.`created`, `Post`.`modified`, `Post`.`status`, `Post`.`allow_comments`, `Post`.`tags`, `Post`.`hitcount`, `Post`.`hitcount_rss` FROM `posts` AS `Post` WHERE `Post`.`url` = 'linux-disk-usage-statistics' LIMIT 1110
8SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`body`, `Comment`.`author`, `Comment`.`url`, `Comment`.`email`, `Comment`.`ip`, `Comment`.`status`, `Comment`.`junk_score`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`status` = 2 AND `Comment`.`post_id` = (70) 110
9SELECT `Tag`.`id`, `Tag`.`tag`, `PostsTag`.`post_id`, `PostsTag`.`tag_id` FROM `tags` AS `Tag` JOIN `posts_tags` AS `PostsTag` ON (`PostsTag`.`post_id` = 70 AND `PostsTag`.`tag_id` = `Tag`.`id`) 220
10SELECT `Category`.`id`, `Category`.`category`, `CategoriesPost`.`post_id`, `CategoriesPost`.`category_id` FROM `categories` AS `Category` JOIN `categories_posts` AS `CategoriesPost` ON (`CategoriesPost`.`post_id` = 70 AND `CategoriesPost`.`category_id` = `Category`.`id`) 110
11UPDATE `posts` AS `Post` SET `Post`.`hitcount` = Post.hitcount + 1 WHERE `Post`.`id` = 7010