如何检查 Linux 中的可用磁盘空间
磁盘

> 
> 用这里列出的方便的工具来跟踪你的磁盘利用率。
> 
> 
> 


![](/data/attachment/album/201807/23/143741g3v54ph5nrqvs34s.jpg)


跟踪磁盘利用率信息是系统管理员（和其他人）的日常待办事项列表之一。Linux 有一些内置的使用程序来帮助提供这些信息。


### df


`df` 命令意思是 “disk-free”，显示 Linux 系统上可用和已使用的磁盘空间。


`df -h` 以人类可读的格式显示磁盘空间。


`df -a` 显示文件系统的完整磁盘使用情况，即使 Available（可用） 字段为 0。


![](/data/attachment/album/201807/23/143803xj0q3jt711u86lbj.png)


`df -T` 显示磁盘使用情况以及每个块的文件系统类型（例如，xfs、ext2、ext3、btrfs 等）。


`df -i` 显示已使用和未使用的 inode。


![](/data/attachment/album/201807/23/143811kct2ozb2oboiie9t.png)


### du


`du` 显示文件，目录等的磁盘使用情况，默认情况下以 kb 为单位显示。


`du -h` 以人类可读的方式显示所有目录和子目录的磁盘使用情况。


`du -a` 显示所有文件的磁盘使用情况。


`du -s` 提供特定文件或目录使用的总磁盘空间。


![](/data/attachment/album/201807/23/143816i5ogql8bjzoou85o.png)


### ls -al


`ls -al` 列出了特定目录的全部内容及大小。


![](/data/attachment/album/201807/23/143818vrh5i4q24iwp48ze.png)


### stat


`stat <文件/目录>`显示文件/目录或文件系统的大小和其他统计信息。


![](/data/attachment/album/201807/23/143823q003ksmdkzw8443g.png)


### fdisk -l


`fdisk -l` 显示磁盘大小以及磁盘分区信息。


![](/data/attachment/album/201807/23/143831s1n8wxw0dneal49j.png)


这些是用于检查 Linux 文件空间的大多数内置实用程序。有许多类似的工具，如 [Disks](https://wiki.gnome.org/Apps/Disks)（GUI 工具），[Ncdu](https://dev.yorhel.nl/ncdu) 等，它们也显示磁盘空间的利用率。你有你最喜欢的工具而它不在这个列表上吗？请在评论中分享。




---


via: <https://opensource.com/article/18/7/how-check-free-disk-space-linux>


作者：[Archit Modi](https://opensource.com/users/architmodi) 选题：[lujun9972](https://github.com/lujun9972) 译者：[MjSeven](https://github.com/MjSeven) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Keeping track of disk utilization information is on system administrators' (and others') daily to-do list. Linux has a few built-in utilities that help provide that information.

[Linux df command](https://opensource.com/article/21/7/check-disk-space-linux-df)

The `df`

command stands for "disk-free," and shows available and used disk space on the Linux system.

`df -h`

shows disk space in human-readable format

`df -a`

shows the file system's complete disk usage even if the Available field is 0

![df command df command](https://opensource.com/sites/default/files/uploads/df-ha.png)

`df -T`

shows the disk usage along with each block's filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)

`df -i`

shows used and free inodes

![df command df command](https://opensource.com/sites/default/files/uploads/df-ti.png)

You can get this information in a graphical view using the **Disks** (gnome-disk-utility) in the GNOME desktop. Launch it to see all disks detected by your computer, and click a partition to see details about it, including space used and space remaining.

![GNOME Disks GNOME Disks](https://opensource.com/sites/default/files/gnome-disks_space.jpg)

opensource.com

[Linux du command](https://opensource.com/article/21/7/check-disk-space-linux-du)


`du`

shows the disk usage of files, folders, etc. in the default kilobyte size

`du -h`

shows disk usage in human-readable format for all directories and subdirectories

`du -a`

shows disk usage for all files

`du -s`

provides total disk space used by a particular file or directory

![du command du command](https://opensource.com/sites/default/files/uploads/du-has.png)

The following commands will check your total space and your utilized space.

This information can be represented visually in GNOME with the **Disk Usage** application, or with **Filelight** in the KDE Plasma desktop. In both applications, disk usage is mapped to concentric circles, with the middle being the base folder (usually your **/home** directory, but it's up to you) with each outer ring representing one directory level deeper. Roll your mouse over any segment for detailed information about what's taking up space.

![Disk usage Disk usage](https://opensource.com/sites/default/files/disk-space.jpg)

opensource.com

## Linux ls -al command

`ls -al`

lists the entire contents, along with their size, of a particular directory

![ls -al command ls -al command](https://opensource.com/sites/default/files/uploads/ls-al.png)

## Linux stat command

`stat <file/directory> `

displays the size and other stats of a file/directory or a filesystem.

![stat command stat command](https://opensource.com/sites/default/files/uploads/stat.png)

## Linux fdisk -l command

`fdisk -l`

shows disk size along with disk partitioning information

![fdisk - l command fdisk - l command](https://opensource.com/sites/default/files/uploads/fdisk.png)

These are most of the built-in utilities for checking file space in Linux. There are many similar tools, like [Disks](https://wiki.gnome.org/Apps/Disks) (GUI), [Ncdu](https://dev.yorhel.nl/ncdu), etc., that also show disk space utilization. Do you have a favorite tool that's not on this list? Please share in the comments.

*This article was originally published in July 2018 and has been updated to include additional information.*

## Comments are closed.