1

I am very new in Ubuntu. I just plugged my mobile in Ubuntu and the two memory cards appears to me. But I was interested to find out the total free space and how much used for each folder. I guess that I have to use df + something.

Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407
DemeCarv
  • 185

1 Answers1

0

No, you won't use df, you'll use du, which is a tool that displays disk usage.

You first need to find out where your mobile phone has been mounted. If you're using Ubuntu 12.10 or later, it'll most likely be mounted under /run/user/<login>/gvfs on a folder called mtp:host=<someNumbers>.

Here is how mine looks like right now:

aa@aa-ul:~$ ls /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/ -l
total 0
drwx------ 1 aa aa 0 Jan  1  1970 Internal storage
drwx------ 1 aa aa 0 Jan  1  1970 SD card

So if I wanted to find out the size of each of the folders under SD card, I would run this command:

du -h -d1 /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SD\ card/

This means:

  • du is the command,
  • -h is to show sizes in human readable format, for example MB or GB,
  • -d1 means go down only one directory (or "folder"). This means "show me the sizes of all the directories inside SD card only, and not the directories inside those directories. If you want to see the sizes of all the subdirectories, remove -d1 from the command, but this will cause the command to take longer and display a lot of lines,
  • /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SD\ card/ is the path.

Here is how my output looks like:

0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/LOST.DIR
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/TWRP
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/.dataviz
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Playlists
512     /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Android
5.2G    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/clockworkmod
760M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/DCIM
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/data
455M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Music
481M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/New folder
6.9G    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/

The total size of the SD card folder is 6.9GB.

I don't know how to show the total free disk space from the command line though. You can see it from the GUI: right click > Properties.

Alaa Ali
  • 32,213