Updated version.
First speed of reading will differ from SSD to HDD and the buffering and caching size.
So I am assuming that you have permission to access folders ( quote "i am not able to get the result in multiple occasion", for some folders you may need privilege to access, otherwise you
may get this message "du: cannot read directory '/direc/tori/ss ': Permission denied")
Based on your
du -hsx * | sort -rh | head -10
h: print sizes in human readable format
s: --summarize you want the total size of directory,(you didn't ask for sub-directory, did you?)
x: you want to "skip directories on different file systems"
sort the result r: reverse and h: human numeric (you need h here because you use it there with du to distigush K,M,G)
head -10 : get the first top 10 of the sorted list
Is there another way beside du? yes, one of them is using ncdu (curses-based version of du)
Explain:
Examine the time (locally) BASED ON MY SYSTEM'S PERFORMANCE
GNU bash, version 5.1.4
For HDD 7200rpm that has 132G of data
Assuming the right directory:
1- time du -hsx * | sort -rh | head -10
real 0m44.978s
user 0m2.432s
sys 0m13.183s
2- time du -B 1 --max-depth=1 | sort -rh | head -10
real 0m43.823s
user 0m2.269s
sys 0m12.879s
real : elapsed time
user,and sys : CPU process time.
If you have big file (say iso file) will show up at the first du, but the second will show you only directories.
In my case without using head:
this is the sizes using your command files and folders
38G,22G,20G,11G,9.6G,6.9G,5.9G,3.2G,3.2G,2.7G,781M,590M,301M,132M,12M,6.9M,6.7M,3.6M,3.5M,276K,224K,25K,4.0K,4.0K,4.0K,512,0
When I use mine (after converting blocks to K,M,G)
123GiB, 38GiB, 22GiB, 20GiB, 11GiB, 9.6GiB, 6.9GiB, 3.2GiB, 3.2GiB, 781MiB, 590MiB, 301MiB, 132MiB, 12MiB, 6.9MiB, 6.7MiB, 3.6MiB, 3.5MiB, 276KiB, 224KiB, 100KiB, 25KiB, 512B
Files didn't show up.
I don't think I need to proof that the SSD is way faster than the HDD.
ncdu 1.15.1 with no sort
real 0m43.550s
user 0m2.742s
sys 0m13.604s
Also ncdu has ssh option for remote connection check it out.
If you are using different shell, update your question and give more information based on the answers and comments you have read.
Finally I don't think the time difference between the two commands are significant, so you can save the result to text file overnight, and sort
it later.
du
command on? This will always be slow (you need to run all thedu
first and only then will you be able to sort and take the top 10, so thehead
won't make any difference to the time taken), but it shouldn't be that slow. I just randu -sch
on a directory of121T
and it finished in a few minutes. What can you tell us about this directory? Does it also contain mount points? – terdon Feb 01 '21 at 17:53du
on the files on it would take hours (even though I'm only using 2 TB of it). – Kusalananda Feb 01 '21 at 21:01ncdu
orbaobab
. But it will also be slow. You need to get the size of each file on the drive. Over the network. Over some VPN connection. What do you expect? Run it directly on the target server and it will be much faster, but probably still slow (but a lot faster), depending on the speed of the disk. – pLumo Feb 03 '21 at 10:59du
know the directory sizes? by going inside and scan each file for its size. For getting to know if the mount is full you might usedf -h /path/to/mountpoint
which is considerably faster – pLumo Feb 03 '21 at 17:15/mnt/some/dir
contains only a single directory,huge
, which is one of the largest directories on the mount point/mnt/some
. What should be reported,/mnt/some/dir/huge
, or/mnt/some/dir
or both? – Kusalananda Feb 04 '21 at 07:57