{"id":8805,"date":"2023-01-10T19:25:19","date_gmt":"2023-01-10T22:25:19","guid":{"rendered":"https:\/\/swiv.com.br\/?p=8805"},"modified":"2026-05-27T20:02:29","modified_gmt":"2026-05-27T19:02:29","slug":"how-to-find-the-largest-files-and-directories","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2023\/01\/10\/how-to-find-the-largest-files-and-directories\/","title":{"rendered":"How to find the largest Files and Directories"},"content":{"rendered":"\n<p>Artigo para uso do dia-a-dia, sobre como identificar os maiores arquivos ou diret\u00f3rios em ambiente Linux\/Unix. No momento do desespero, com o ambiente parado com 100% de FS utilizado, pode ajudar.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Files<\/h2>\n\n\n\n<p>Exemplo onde entro em um diret\u00f3rio de meu interesse, que ser\u00e1 alvo do comando &#8220;find .&#8221; Ap\u00f3s isso, \u00e9 exibido os 5 maiores arquivos (j\u00e1 ordenados em forma decrescente):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@solariSWIV:\/var# pwd\n\/var\nroot@solariSWIV:\/var# find . -ls | sort -nrk7 | head -5\n151175 36125 -rw-r--r--   1 root     sys      36852732 Aug 20  2018 .\/pkg\/cache\/actions.stripped\n148506 22292 -r--r--r--   1 root     bin      22794033 Aug 20  2018 .\/db\/stackdb\/stackdb\n13472 19345 -rw-r--r--   1 root     root     19692362 Aug 20  2018 .\/pkg\/state\/known\/catalog.summary.C\n13462 18321 -rw-r--r--   1 root     root     18657670 Jul 13  2018 .\/pkg\/publisher\/solaris\/origins\/9b4531c13be9b35055178bc2fbd4b35375eacf45\/catalog.summary.C\n13474 15116 -rw-r--r--   1 root     root     15412040 Aug 20  2018 .\/pkg\/state\/known\/catalog.dependency.C\nroot@solariSWIV:\/var#\n<\/pre><\/div>\n\n\n<p>Caso queiramos filtrar pela extens\u00e3o do arquivo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@solariSWIV:\/var# find . -name &quot;*.stripped&quot; -ls | sort -nrk7 | head\n151175 36125 -rw-r--r--   1 root     sys      36852732 Aug 20  2018 .\/pkg\/cache\/actions.stripped\nroot@solariSWIV:\/var#\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Directories<\/h2>\n\n\n\n<p>O comando abaixo retorna os 5 diret\u00f3rios que est\u00e3o consumindo mais espa\u00e7o a partir do diret\u00f3rio que \u00e9 disparado:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel8 oracle]$ du -S . | sort -nr | head -5\ndu: cannot read directory &#039;.\/18.0.0\/base\/tfa&#039;: Permission denied\n2926364 .\/SINAPSE\/dados\/SINAPSE\/datafile\n2524048 .\/dados\/RMANDB\/datafile\n2382420 .\/18.0.0\/product\/lib\n1834208 .\/archives\n1248092 .\/SINAPSE\/archives\n<\/pre><\/div>\n\n\n<p>Caso n\u00e3o queiramos as mensagens de erro (por exemplo de permiss\u00e3o negada), podemos executar:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel8 oracle]$ du -S . 2&gt;\/dev\/null | sort -nr | head -5\n2926364 .\/SINAPSE\/dados\/SINAPSE\/datafile\n2524048 .\/dados\/RMANDB\/datafile\n2382420 .\/18.0.0\/product\/lib\n1834208 .\/archives\n1248092 .\/SINAPSE\/archives\n&#x5B;oracle@oel8 oracle]$\n<\/pre><\/div>\n\n\n<p>Nota 1: A op\u00e7\u00e3o &#8220;-S&#8221; n\u00e3o inclui o tamanho dos subdiret\u00f3rios. Caso este seja o objetivo, \u00e9 s\u00f3 omitir.<\/p>\n\n\n\n<p>Nota 2: A op\u00e7\u00e3o &#8220;-S&#8221; n\u00e3o foi reconhecida em meu teste em Oracle Solaris 11:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@solariSWIV:\/var# du -S . | sort -nr | head -5\ndu: illegal option -- S\nusage: du &#x5B;-dorx] &#x5B;-a|-s] &#x5B;-h|-k|-m] &#x5B;-H|-L] &#x5B;file...]\nroot@solariSWIV:\/var# du . | sort -nr | head -5\n799625  .\n710205  .\/pkg\n310250  .\/pkg\/cache\n275912  .\/pkg\/publisher\n275909  .\/pkg\/publisher\/solaris\nroot@solariSWIV:\/var#\n<\/pre><\/div>\n\n\n<p>Para termos o mesmo efeito, basta substituis o &#8220;-S&#8221; por &#8220;-o&#8221;:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@solariSWIV:\/var# du -o . | sort -nr | head -5\n94799   .\/pkg\/cache\n76102   .\/pkg\/state\/known\n69955   .\/pkg\/publisher\/solaris\/origins\/9b4531c13be9b35055178bc2fbd4b35375eacf45\n44586   .\/db\/stackdb\n21524   .\/cache\/fontconfig\nroot@solariSWIV:\/var#\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Artigo para uso do dia-a-dia, sobre como identificar os maiores arquivos ou diret\u00f3rios em ambiente Linux\/Unix. No momento do desespero, com o ambiente parado com 100% de FS utilizado, pode ajudar. Files Exemplo onde entro em um diret\u00f3rio de meu interesse, que ser\u00e1 alvo do comando &#8220;find .&#8221; Ap\u00f3s isso, \u00e9 exibido os 5 maiores [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-8805","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/8805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=8805"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/8805\/revisions"}],"predecessor-version":[{"id":9023,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/8805\/revisions\/9023"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=8805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=8805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=8805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}