How can I check disk space used in a partition using the terminal in Ubuntu 12.04 LTS? [duplicate]
The su
command is completely irrelevant. The disk usage is the same for all users. Anyway, some relevant commands and their output on my system are:
terdon@oregano ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda7 68G 23G 43G 35% /
udev 10M 0 10M 0% /dev
tmpfs 800M 1.6M 798M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.2G 12M 3.2G 1% /run/shm
/dev/sda6 290G 256G 20G 94% /home
tmpfs 3.2G 992K 3.2G 1% /tmp
none 4.0K 0 4.0K 0% /sys/fs/cgroup
/dev/sdc1 466G 379G 88G 82% /media/terdon/Iomega_HDD
For a specific partition:
terdon@oregano ~ $ df -h /dev/sda7
Filesystem Size Used Avail Use% Mounted on
/dev/sda7 68G 23G 43G 35% /
Alternatively, though this only lists the size, not the %used:
terdon@oregano ~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 39.2M 0 part
├─sda2 8:2 0 14.7G 0 part
├─sda3 8:3 0 78.1G 0 part
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part
├─sda6 8:6 0 294.4G 0 part /home
├─sda7 8:7 0 68.7G 0 part /
└─sda8 8:8 0 7.8G 0 part [SWAP]
sdc 8:32 0 465.8G 0 disk
└─sdc1 8:33 0 465.8G 0 part /media/terdon/Iomega_HDD
sr0 11:0 1 1024M 0 rom
Conversely, you can use the du
command to print directory size which will give you the disk usage of a partition if you run it on a partition's mountpoint: du -xsch /home
for example. The -x
option will "skip directories on different file systems," which is helpful if you have other mount points nested below the partition's mount point (typically /
).
You can use df -Th
to get the used space of partitions:
$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda9 ext4 22G 16G 4.8G 77% /
none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup
udev devtmpfs 1.5G 4.0K 1.5G 1% /dev
tmpfs tmpfs 297M 1.4M 295M 1% /run
none tmpfs 5.0M 4.0K 5.0M 1% /run/lock
none tmpfs 1.5G 616K 1.5G 1% /run/shm
none tmpfs 100M 68K 100M 1% /run/user
/dev/sda5 fuseblk 53G 34G 19G 65% /media/Songs
/dev/sda7 fuseblk 103G 90G 14G 88% /media/Data
/dev/sda6 fuseblk 69G 34G 35G 50% /media/Movies
/dev/sda1 fuseblk 49G 36G 14G 72% /media/guru/0C64A7F864A7E326
You can also provide it with a specific partition if you want to view disk utilization of only that partition:
$ df -Th /dev/sda9
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda9 ext4 22G 16G 4.8G 77% /
You can also use pydf
or discus
to get better representation in terminal.
You need to install these if you want to use it. Type:
sudo apt-get install pydf
in terminal to install pydf
.
$ pydf
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 22G 16G 4893M 72.7 [#########################.........] /
/dev/sda7 103G 90G 13G 87.2 [##############################....] /media/Data
/dev/sda6 69G 34G 35G 49.3 [#################.................] /media/Movies
/dev/sda5 53G 34G 19G 64.5 [######################............] /media/Songs
/dev/sda1 49G 35G 14G 71.9 [########################..........] /media/guru/0C64A7F864A7E326