du is a unix command to measure disk usage
Questions tagged [du]
193 questions
10
votes
7 answers
Why does "find . -name *.txt | xargs du -hc" give multiple totals?
I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works:
find . -name *.txt | xargs du -hc
But instead of giving me one total at the end, I get several.…
Alex
9
votes
4 answers
How to monitor the size of a directory via Telegraf
We need to monitor the size of a directory (for example the data directory of InfluxDB) to set up alerts in Grafana. As mentioned here: How to configure telegraf to send a folder-size to influxDB , there is no built-in plugin for this.
We don't mind…

Tw Bert
- 3,659
- 20
- 28
9
votes
3 answers
Size() vs ls -la vs du -h which one is correct size?
I was compiling a custom kernel, and I wanted to test the size of the image file.
These are the results:
ls -la | grep vmlinux
-rwxr-xr-x 1 root root 8167158 May 21 12:14 vmlinux
du -h vmlinux
3.8M vmlinux
size vmlinux
text data …

chettyharish
- 1,704
- 7
- 27
- 41
8
votes
2 answers
Why is du command showing double size when h flag is sent?
I want to check the total size of a git repository. Is funny that du is giving me two different kind of sizes when the -h flag is sent. It is actually giving double size.
Why is this? What is the correct size?
MyMac:~/repositories/my-repo.git…

David Rz Ayala
- 2,165
- 1
- 20
- 22
7
votes
3 answers
Why du or echo pipelining is not working?
I'm trying to use du command for every directory in the current one. So I'm trying to use code like this:
ls | du -sb
But its not working as expected. It outputs only size of current '.' directory and thats all.
The same thing is with echo
ls |…

Unicorn
- 1,397
- 1
- 15
- 24
7
votes
6 answers
Fast(er) way to get folder size with batch script
PLEASE SEE BELOW THE ORIGINAL QUESTION FOR SOME TEST COMPARISONS OF DIFFERENT WAYS:
So I tried 2 ways so far:
1.Iterate through directory using the code from Get Folder Size from Windows Command Line :
@echo off
set size=0
for /r %%x in (folder\*)…

StanM
- 827
- 4
- 12
- 33
7
votes
4 answers
Directory Stats command line interface?
Windirstat/ Kdirstat/ Disk Inventory X has been nothing short of revolutionary in file managment. Why is there no text-only command line equivalent? I'd need it for SSH administration of my file servers.
We have all the building blocks: du, tree…

Sridhar Sarnobat
- 25,183
- 12
- 93
- 106
6
votes
2 answers
Using BASH, how would one use "du -ch" to output only the total collective size?
I'm trying to run du -ch on multiple directories, but I only apart it only shows the total size of all files (I don't want each individual file, then the total at the end which is what -cdoes).
user5849928
6
votes
1 answer
How to gather disk usage on a storage system faster than just using "du"?
I operates a Synology NAS device and the unit includes that over 600 users data.
The users backup data are tax accounting data.
So, approximately one user's folder has 200,000 files.
I have to provide their backup data usage informations to each…

Tommy
- 81
- 1
- 1
- 3
5
votes
2 answers
Diffrence between real and showed by docker system df disc usage
I have docker in version 18.03.1-ce that support command docker system df. His output:
Images space usage:
REPOSITORY TAG IMAGE ID CREATED ago SIZE SHARED SIZE …

Daniel
- 7,684
- 7
- 52
- 76
5
votes
3 answers
du -skh * in / returns vastly different size from df on centos 5.5
I have a vps slice running centos 5.5 I am supposed to have 15 gigs of disk space, but according to df it seems to double my disk space usage.
when I run du -skh * in / as root i get:
[root@yardvps1 /]# du -skh *
0 aquota.group
0 …

Kalendae
- 2,256
- 1
- 21
- 23
5
votes
1 answer
How does du calculate the size of a file in kilobytes?
I have a file for which
du -b filename gives 67108864 as the answer (which is supposed to be in bytes),
while
du filename gives 65604 (which is supposed to be in kilobytes).
However, it should return 67108864/1024 = 65536 as the answer.
I looked at…

piedpiper
- 1,222
- 3
- 14
- 27
4
votes
1 answer
Show DU outcome in purely megabytes
I am using DU function to output the directory size to a file and then move it to an excel file to add the total. Is it possible to output the size of a directory only in MB (even if the size is in KB or GB):
e.g. if the file size is 50kb the output…

joebegborg07
- 821
- 3
- 14
- 27
4
votes
1 answer
How do I use the -I option of du to ignore all files of a given type?
Hello I am running OS X.
I am trying to use du and the -I option to ignore all files of a given type.
I am resorting to -I because OS X du doesnt include the "exclude" option.
Essentially I am trying to find the OS X equivalent to this command:
du…

Thomas Padilla
- 193
- 1
- 1
- 7
4
votes
2 answers
formatting du -sh output
I would like to customize the output from:
du -hs *
E.g output:
23G Test1
1.2M Folder With Spaces
12G Another Folder With Spaces
The problem is that I can capture the first column but since the second column may contain spaces the output…

mac2017
- 445
- 1
- 6
- 16