• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help ADB Command to show folder sizes

El Presidente

Beware The Milky Pirate!
I've just picked up a Kindle Fire stick and need (or want) to know why yesterday I had circa 5GB free space on it and today I have 2GB.

I'm aware "df" will show me a list of partitions and the space they're allocated, but is there a command which will show me which folders are taking up what space?

The PC doesn't pick it up so the only way I'm able to talk to the device properly is using the Wireless ADB Shell function of an app called adbfire.
 
Hey EP! :)

I think du is what you're looking for:

ScaryAlien@LV-426 ~
$
adb shell
shell@hammerhead:/ $ cd /sdcard
shell@hammerhead:/sdcard $ du -ks *
4 Alarms
187632 Android
4 Books
226632 DCIM
624 Download
4 Movies
4 Music
60 Notifications
8 Pictures
4 Podcasts
112 Ringtones
404 SH_IMAGES
704 SpeedSoftware
4225528 TWRP
8064 TitaniumBackup
3924 UPDATE-SuperSU-v2.46.zip
8 afwall
244 amazon
208 calvin-and-hobbes.jpg
4 cameras-2015-05-30.xml
4 cameras.xml
8 clockworkmod
2156 data
12 dropsync
28 dropsync.log
512 fsc.img
8 kindle
56 loopmount-test
880 mSecure
4 panoramas
4 sa.sh
12 sms-table.csv
12 smsmms.csv
228 starry-starry-night.jpg
4 temp
172 un-root-me
152 zedge
shell@hammerhead:/sdcard $

It doesn't really display/differentiate what is a folder, but it will show you the total size of each.

The -ks switch tells him to display things in kilobytes and summarizes the folder.

I'll post back with another command option/variant...just a sec...

:)
 
Do you need to be rooted for "du -ks" to work?

I get "Permission Denied" errors for everything -

Code:
du: ./proc/8874/task/8879/ns: Permission denied
du: ./proc/8874/task/8880/fd: Permission denied
du: ./proc/8874/task/8880/fdinfo: Permission denied
du: ./proc/8874/task/8880/ns: Permission denied
du: ./proc/8874/task/8881/fd: Permission denied
du: ./proc/8874/task/8881/fdinfo: Permission denied
du: ./proc/8874/task/8881/ns: Permission denied
du: ./proc/8874/task/8882/fd: Permission denied
du: ./proc/8874/task/8882/fdinfo: Permission denied
 
Ah, well that's because the folders / directories that you're trying to traverse are indeed read-protected. So, you'll need appropriate access (root) for those protected areas, of course.
 
Also, here's a command to show you sizes of just the directories in the current path (this is somewhat "fragile" since the offset to the filename output (at columns 57) is hard-coded)):

shell@hammerhead:/sdcard $ ls -l | grep "^d" | cut -c 57- | xargs du -ks
4 Alarms
187632 Android
4 Books
226632 DCIM
624 Download
4 Movies
4 Music
60 Notifications
8 Pictures
4 Podcasts
112 Ringtones
404 SH_IMAGES
704 SpeedSoftware
31224 TWRP
8064 TitaniumBackup
8 afwall
244 amazon
8 clockworkmod
2156 data
12 dropsync
8 kindle
56 loopmount-test
880 mSecure
4 panoramas
4 temp
172 un-root-me
152 zedge

There's other commands, too...lemme play with the "find" command next...

meh--scratch that...the find command is pretty crippled in Android's shell :(
 
Last edited:
Couple more examples / different spins on the du command (this time with su / root):

root@hammerhead:/ # du -d 1 -H / 2> /dev/null | sort -r -n
7078736 /
4575552 /data
2003184 /system
302952 /mnt
100984 /storage
90816 /firmware
1424 /sbin
1232 /su
264 /persist
248 /cache
160 /dev
24 /sys
16 /res
0 /root
0 /proc
0 /oem
0 /config
0 /acct

root@hammerhead:/ # du -d 1 -H /data 2> /dev/null | sort -r -n
4575560 /data
3054344 /data/app
1127688 /data/dalvik-cache
258368 /data/data
100984 /data/media
4192 /data/system
3032 /data/misc
72 /data/property
48 /data/backup
40 /data/mediadrm
40 /data/drm
16 /data/tombstones
16 /data/nfc
16 /data/local
8 /data/user
8 /data/ss
8 /data/security
8 /data/resource-cache
8 /data/lost+found
8 /data/bootchart
8 /data/app-private
8 /data/app-lib
8 /data/app-asec
8 /data/adb
 
The System Data folder on my Samsung Galaxy S9+ has been growing like a cancer every day for months. I have not been able to figure out the source of the problem, but this ADB command seems like a promising way to see what folders or files in System are taking up all of that space. However, is it true that I'll need to root my phone to use this ADB command on the System folder? I don't need to write anything. I just want to see what files or folders are gigantic since that might give me insight as to what is causing the problem. I don't want to root my phone, so I'm guessing that this ADB command will not help me, but I just wanted to double check. Is there any way to figure out what is taking up all that space in System Data without rooting my phone?
upload_2021-1-31_17-26-33.png
 
Back
Top Bottom