1 2 3 4 5 6 7 8 |
alias dud='du -chd 1' alias dud2='du -chd 2' alias dud3='du -chd 3' alias dud4='du -chd 4' alias duds='du -chd 1 | sort -h' alias duds2='du -chd 2 | sort -h' alias duds3='du -chd 3 | sort -h' alias duds4='du -chd 4 | sort -h' |
1 2 3 4 5 6 7 8 |
alias dud='du -ch --max-depth 1' alias dud2='du -ch --max-depth 2' alias dud3='du -ch --max-depth 3' alias dud4='du -ch --max-depth 4' alias duds='du -ch --max-depth 1 | sort -h' alias duds2='du -ch --max-depth 2 | sort -h' alias duds3='du -ch --max-depth 3 | sort -h' alias duds4='du -ch --max-depth 4 | sort -h' |
So the above commands are useful to recursively measure the size of directories. Note the dud commands can be thrown in together with an “-x” argument to stay within the filesystem.
1 2 3 4 5 |
dud -x dud1 -x dud2 -x dud3 -x dud4 -x |
Here are some example outputs of all of the above commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
###################### ##### du depth 1 ##### ###################### # dud 0 ./opt 63M ./backups 0 ./agentx 0 ./local 121M ./log 8.0K ./spool 0 ./mail 223M ./cache 64M ./lib 0 ./tmp 4.0K ./www 8.0K ./netatalk 36M ./cores 0 ./ftp 660K ./readynasd 8.0K ./readydrop 0 ./replicate 505M . 505M total ############################# ##### du depth 1 sorted ##### ############################# # duds 0 ./agentx 0 ./ftp 0 ./local 0 ./mail 0 ./opt 0 ./replicate 0 ./tmp 4.0K ./www 8.0K ./netatalk 8.0K ./readydrop 8.0K ./spool 660K ./readynasd 36M ./cores 63M ./backups 64M ./lib 121M ./log 223M ./cache 505M . 505M total ############################# ##### du depth 2 sorted ##### ############################# # duds2 0 ./agentx 0 ./cache/apache2 0 ./cache/forked-daapd 0 ./cache/git 0 ./cache/man 0 ./ftp 0 ./lib/dbus 0 ./lib/ftp 0 ./lib/initscripts 0 ./lib/insserv 0 ./lib/libuuid 0 ./lib/misc 0 ./lib/nfs 0 ./lib/nut 0 ./lib/python 0 ./lib/systemd 0 ./lib/update-rc.d 0 ./lib/urandom 0 ./lib/vim 0 ./local 0 ./log/fsck 0 ./log/news 0 ./log/sysstat 0 ./mail 0 ./netatalk/CNID 0 ./opt 0 ./replicate 0 ./replicate/shm 0 ./spool/netatalk 0 ./tmp 4.0K ./lib/btrfs 4.0K ./lib/mdadm 4.0K ./lib/sudo 4.0K ./spool/cron 4.0K ./www 8.0K ./lib/snmp 8.0K ./netatalk 8.0K ./readydrop 8.0K ./spool 16K ./cache/ldconfig 20K ./lib/connman 24K ./lib/pam 24K ./lib/ucf 28K ./cache/fontconfig 36K ./log/apache2 100K ./log/apt 156K ./log/readynasd 440K ./cache/samba 456K ./log/samba 660K ./readynasd 1.8M ./cache/debconf 2.2M ./backups/md 2.5M ./backups/readynasd 2.6M ./lib/samba 3.7M ./log/frontview 14M ./lib/dpkg 18M ./lib/gems 30M ./lib/apt 32M ./log/journal 36M ./cores 63M ./backups 64M ./lib 83M ./log/atop 121M ./log 221M ./cache/apt 223M ./cache 505M . 505M total ########################################## ##### du depth 1 within 1 filesystem ##### ########################################## # Notice how since /data is a different subvolume (btrfs filesystem here), then /data/home and /data/so-and-so, so all of those so-and-so (home as well) ones show up as 0 size. Because we are staying within the /data filesystem (as we are in /data when we run "dud -x"). And each subvolume behaves as its own filesystem with btrfs. /data# dud -x 0 ./home 0 ./.apps 0 ./.vault 0 ./._share 0 ./.purge 0 ./Main 0 ./readydrop 0 ./.timemachine 36K . 36K total # Here is the same command but letting du flow freely into any filesystem (subvolume), so it measures all of the sizes. /data# dud 0 ./home 2.2M ./.apps 0 ./.vault 64K ./._share 0 ./.purge 2.7T ./Main 0 ./readydrop 0 ./.timemachine 2.7T . 2.7T total |