Disk space is no longer as precious as it was in the early days of computers, but no matter how much disk space you have, there is always a possibility of running out. Computers need some disk space to start and run, so it is necessary to occasionally check to ensure that you have not inadvertently used up all the hard disk space. In the Linux terminal, you can use the df command to do this.
The df command displays the available disk space in the file system.
To make the output easier to read, you can add the --human-readable (or its shorthand -h) option:
$ df --human-readable
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.0T 525G 500G 52% /
In this example, the computer's disk is 52% used, with 500 GB of available space.
Since Linux treats the file systems of all mounted devices as a whole, the df command will display detailed information about each storage device connected to the computer. If you have many disks, the output will reflect this:
$ df --human-readable
Filesystem Size Used Avail Use% Mounted on
/dev/root 110G 45G 61G 43% /
devtmpfs 12G 0 12G 0% /dev
tmpfs 12G 848K 12G 1% /run
/dev/sda1 1.6T 1.3T 191G 87% /home
/dev/sdb1 917G 184G 687G 22% /penguin
/dev/sdc1 57G 50G 4.5G 92% /sneaker
/dev/sdd1 3.7T 2.4T 1.3T 65% /tux
In this example, the /home directory on the computer is 87% used, with 191 GB of available space.
Check Total Available Disk Space#
If your file system is complex and you want to see the total space of all disks, you can use the --total option:
$ df --human-readable --total
Filesystem Size Used Avail Use% Mounted on
/dev/root 110G 45G 61G 43% /
devtmpfs 12G 0 12G 0% /dev
tmpfs 12G 848K 12G 1% /run
/dev/sda1 1.6T 1.3T 191G 87% /home
/dev/sdb1 917G 184G 687G 22% /penguin
/dev/sdc1 57G 50G 4.5G 92% /sneaker
/dev/sdd1 3.7T 2.4T 1.3T 65% /tux
total 6.6T 4.0T 2.5T 62% -
The last line of the output shows the total space, total used space, and total available space of the file system.
Check Disk Space Usage#
If you want to get a rough idea of which files are taking up disk space, please read our article about the du command[1].
via:
https://opensource.com/article/21/7/check-disk-space-linux-df
https://linux.cn/article-13646-1.html