{"id":643,"date":"2010-12-10T10:36:43","date_gmt":"2010-12-10T15:36:43","guid":{"rendered":"http:\/\/it.thelibrarie.com\/weblog\/"},"modified":"2010-12-17T14:41:40","modified_gmt":"2010-12-17T19:41:40","slug":"linux-show-directory-sizes","status":"publish","type":"page","link":"https:\/\/it.thelibrarie.com\/weblog\/linux-show-directory-sizes\/","title":{"rendered":"Linux Show Directory Sizes"},"content":{"rendered":"<p>I think we all know how to show how much each MAJOR directory is using:<br \/>\n<code>df -h<\/code><br \/>\n<a href=\"http:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/dfh.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/dfh.png\" alt=\"\" title=\"dfh\" width=\"577\" height=\"176\" class=\"alignnone size-full wp-image-644\" srcset=\"https:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/dfh.png 577w, https:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/dfh-300x91.png 300w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/a><\/p>\n<p>But what if I wanted to see inside a few further directories?<br \/>\n<code>du<\/code><br \/>\nYes, du.  Du &#8211; estimates file space usage.<\/p>\n<p>So, in my case, I could do the following:<br \/>\n<code>du -hc --max-depth=1 | grep M<\/code><br \/>\nThat checks, in human terms, with a max depth of 1, how many directories have X number of MB.<br \/>\nYou can also replace the M with G or T to list directories in the GB range or the TB range.<br \/>\n<a href=\"http:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/duhc.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/duhc.png\" alt=\"\" title=\"duhc\" width=\"412\" height=\"128\" class=\"alignnone size-full wp-image-645\" srcset=\"https:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/duhc.png 412w, https:\/\/it.thelibrarie.com\/weblog\/wp-content\/uploads\/2010\/12\/duhc-300x93.png 300w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/a><\/p>\n<p>Be warned though, Grepping for M or G can also yield some files with those names.<\/p>\n<p>ALSO I wanted to find files edited in the past &#8220;x&#8221; days or hours:<br \/>\nFind all files modified in the past 2 days:<br \/>\n<code>find \/ -mtime -2 -ls<\/code><\/p>\n<p>Find all files modified in the past 20 minutes:<br \/>\n<code>find \/ -mmin -20 -ls<\/code><\/p>\n<p>List all open items on linux:<br \/>\nlsof > file.txt<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think we all know how to show how much each MAJOR directory is using: df -h But what if I wanted to see inside a few further directories? du Yes, du. Du &#8211; estimates file space usage. So, in my case, I could do the following: du -hc &#8211;max-depth=1 | grep M That checks, &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/linux-show-directory-sizes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Linux Show Directory Sizes<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-643","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/pages\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":4,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/pages\/643\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/pages\/643\/revisions\/654"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}