How To Get File System Disk Usage
When administrating Linux systems we can found us tracking disk usage. Linux uses different partitions to store data. There are some temp files located in /tmp or different paths. Some applications are installed into the /opt path. So managing paths and disk usage may become hard in linux. There are some GUI applications like KDirStat but they are useful for only GUI environments. We will look different commands in this tutorial to get disk usage.
Get Disk Usage With df
We can simple issue df command and get disk usage in Kilobyte like below
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 8377344 4554360 3822984 55% /
devtmpfs 489736 489736 % /dev
tmpfs 508312 508312 % /dev/shm
tmpfs 508312 7052 501260 2% /run
tmpfs 508312 508312 % /sys/fs/cgroup
tmpfs 101664 101664 % /run/user/
Let’s make it more readable by using gigabyte output.
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 8.0G 4.4G 3.7G 55% /
devtmpfs 479M 479M % /dev
tmpfs 497M 497M % /dev/shm
tmpfs 497M 6.9M 490M 2% /run
tmpfs 497M 497M % /sys/fs/cgroup
tmpfs 100M 100M % /run/user/
If you like the old days by out size with megabyte use below command.
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/vda1 8181 4448 3734 55% /
devtmpfs 479 479 % /dev
tmpfs 497 497 % /dev/shm
tmpfs 497 7 490 2% /run
tmpfs 497 497 % /sys/fs/cgroup
tmpfs 100 100 % /run/user/
Getting Usage With ncdu
ncdu is text-based disk usage viewer which can be found in Fedora,Ubuntu, Debian distributions. Sadly it is not provieded by CentOS default repositories.
$ sudo ncdu /
- We need root privilege to scan all root directory
And here after running ncdu we get following screen.