baicai

白菜

一个勤奋的代码搬运工!

Use the df command to view available disk space on Linux.

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 that you haven't inadvertently used up all your hard drive space. In the Linux terminal, you can do this with the df command.

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 already 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 multiple disks, the output will reflect that:

$ 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 already 87% used, with 191 GB of available space.

Checking the Total Available Disk Space#

If your file system is indeed 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.

Checking 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

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.