{"id":185,"date":"2015-04-27T13:25:11","date_gmt":"2015-04-27T13:25:11","guid":{"rendered":"http:\/\/betakb.veeble.org\/?p=185"},"modified":"2025-04-22T13:02:11","modified_gmt":"2025-04-22T07:32:11","slug":"disk-usage-du-command","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/disk-usage-du-command\/","title":{"rendered":"Disk Usage &#8211; DU command"},"content":{"rendered":"\n<p>DU is the short form of Disk Usage.<\/p>\n\n\n\n<p>The Linux du command is used to find out the disk usage in terms of file size and in human readable format. It can be used to get the size of the folders and the total usage. The usage of the command DU is very easy and some of them are explained below.<\/p>\n\n\n\n<p>Pasted below are some usages of DU command.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"1-basic-usage-of-du\">1. Basic usage of du<\/h3>\n\n\n<pre class=\"wp-block-preformatted\"># du \n4       .\/myfile\n4       .\/user\/checkfile\n4       .\/john\n12      .\/sam\n24      .\n<\/pre>\n\n\n\n<p>The command du -a is used to get the disk usage of all the files and directories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -a\n4       .\/myfile\n4       .\/user\/checkfile\n4       .\/john\n12      .\/sam\n24      .\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"2-display-output-in-humanreadable-format\">2. Display output in human-readable format<\/h3>\n\n\n<p>The command du -h is used to print the information in a human-readable format.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -ah\n4.0K       .\/myfile\n4.0K       .\/user\/checkfile\n4.0K       .\/john\n12.0K      .\/sam\n24K        .\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"3-display-grand-total-of-the-space-usage-in-the-output\">3. Display grand total of the space usage in the output.<\/h3>\n\n\n<p>The command du -c is used to get the grand total of its usage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -ach\n4.0K       .\/myfile\n4.0K       .\/user\/checkfile\n4.0K       .\/john\n12.0K      .\/sam\n24K        .\n24K     total\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"4-display-only-the-total-count-of-the-disk-usage\">4. Display only the total count of the <mark>disk usage<\/mark><\/h3>\n\n\n<p>To get the total amount of disk usage, the is command du -s<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -sh\n24K     .\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"5-customize-the-block\">5. Customize the block<\/h3>\n\n\n<p>The output can be produced in such a way that the disk usage of the files and the directories are displayed on the basis of the block size. In the default setting, it displays the block size as KB(1024 Bytes). It can be changed to a different block size depending on the need.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -ach\n4.0K       .\/myfile\n4.0K       .\/user\/checkfile\n4.0K       .\/john\n12.0K      .\/sam\n24K        .\n24K     total\n<\/pre>\n\n\n\n<p>When changing the block size to 2048(2KB), the output will be the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -ahc --block-size=2048\n2       .\/example\n2       .\/test1\n2       .\/redhat\/demo\n2       .\/redhat\/test\n6       .\/redhat\n12      .\n12      total\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"6-display-output-in-bytes\">6. Display output in bytes<\/h3>\n\n\n<p>To display the output in bytes the command is du -b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -b\n4096    .\/myfile000\n4096    .\/admin\/check\n4096    .\/one\/two\n12288   .\/final\n20529   .\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"7-exclude-particular-types-of-files\">7. Exclude particular types of file(s)<\/h3>\n\n\n<p> In order to not display the information about a particular type of file or files in the output the command du &#8211;exclude come into use<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ll\ntotal 16\n-rw-r--r-- 1 root root   49 Sep  4 15:40 work\n-rw-r--r-- 1 root root   32 Sep  4 16:15 seeyou\n-rw-r--r-- 1 root root    0 Sep  4 16:19 work.doc\n-rw-r--r-- 1 root root    0 Sep  4 16:19 work1.txt\n-rw-r--r-- 1 root root    0 Sep  4 16:19 seeyou.doc\n-rw-r--r-- 1 root root    0 Sep  4 16:19 work2.txt\n<\/pre>\n\n\n\n<p>When using the du -exclude command the output will be as follows<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -ah --exclude=\"*.txt\"\n4.0K    .\/user2\n4.0K    .\/normalfile\n0       .\/check.doc\n0       .\/resume.doc\n0       .\/cv.doc\n0       .\/ace.doc\n4.0K    .\/blue\n4.0K    .\/office\n4.0K    .\/office\/desk\n12K     .\/yellow\n0       .\/orange\n28K     .\n<\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"8-display-the-modification-time-and-customize-the-display-style\">8. Display the modification time and customize the display style<\/h3>\n\n\n<p>The commands du -time and du -time-style are the ones for the above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># du -cbha --time\n49      2013-09-04 15:40        .\/car\n4.0K    2013-09-04 15:39        .\/buy\n4.0K       2013-09-04 16:19        .\/ticket.txt\n8K     2013-09-04 16:26        total<\/pre>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-93d55b1d wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Unlock Unlimited Hosting Opportunities<\/h3><p class=\"uagb-cta__desc\">From startups to enterprises, serve every client with flexible plans, unlimited domains, and a 100% white-label experience.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/reseller-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Explore Plans<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>DU is the short form of Disk Usage. The Linux du command is used to find out the disk usage in terms of file [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":8131,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2015\/04\/Disk-Usage-DU-command.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Vipin Raj","author_link":"https:\/\/www.veeble.com\/kb\/author\/vipin\/"},"uagb_comment_info":1,"uagb_excerpt":"DU is the short form of Disk Usage. The Linux du command is used to find out the disk usage in terms of file [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":6,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":8670,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/185\/revisions\/8670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/8131"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}