
linux磁盘空间
Disk usage and monitoring is important aspect of Linux system administration. One of the most occurring problems is fulling disk space. Getting information about disk usage can become a nightmare if you do not know how to properly do it. How many free GB are there? or How many percentages of the disk is full?
磁盘使用和监视是Linux系统管理的重要方面。 发生最多的问题之一是磁盘空间已满。 如果您不知道如何正确使用磁盘,则获取有关磁盘使用情况的信息可能会成为噩梦。 有多少可用GB? 或多少百分比的磁盘已满?
用df命令检查 (Check with df Command)
To check disk space usage df command can be used. df command will give general information about disk usage. We will also provide the -l
and -h
options in order to list partitions in a human-readable format.
要检查磁盘空间使用情况,可以使用df命令。 df命令将提供有关磁盘使用情况的常规信息。 我们还将提供-l
和-h
选项,以便以人类可读的格式列出分区。
$ df -lh

We will get the following information about the disk space and size.
我们将获得有关磁盘空间和大小的以下信息。
- `Size` is the complete size of the given partition or disk. “大小”是给定分区或磁盘的完整大小。
- `Used` is the size which is already used or filled in a given disk or partition. “已使用”是给定的磁盘或分区中已使用或已填充的大小。
- `Available` is the size which is spare in a given disk or partition. “可用”是在给定磁盘或分区中备用的大小。
- `Use` is the percentage of the used part of the given disk or partition. “使用”是给定磁盘或分区的已用部分的百分比。
用du命令检查 (Check with du Command)
An alternative to df command is du command. Actually, they provide different information from a different viewpoint. Du command provides information about files and directories.
df命令的替代方法是du命令。 实际上,它们从不同的角度提供不同的信息。 Du命令提供有关文件和目录的信息。
$ sudo du -sh /* 2> /dev/null

The command may seem a bit complex. We get size summary information about directories in root path level and to clear standard error messages send them to the /dev/nul
该命令似乎有点复杂。 我们在根路径级别获取有关目录的大小摘要信息,并清除标准错误消息,并将它们发送到/ dev / nul
根据目录大小对目录进行排序 (Sort Directories According To Their Size)
We can list root-level directories according to their size in KB. Listing them according to their size is not so complex.
我们可以根据根目录的大小(KB)列出它们。 根据它们的大小列出它们并不那么复杂。
$ sudo du -s /* 2> /dev/null | sort -n -r

远程检查磁盘空间(Check Disk Space Remotely)
Checking disk space usage one by one connecting to the servers is a tedious task. It can be done remotely with ssh connection. By using ssh remote command execution feature disk command can be run without connecting to server.
逐一检查连接到服务器的磁盘空间使用情况是一项繁琐的任务。 可以通过ssh连接远程完成。 通过使用ssh远程命令执行功能,可以在不连接服务器的情况下运行disk命令。
$ ssh ubu1 "du -s /* 2> /dev/null | sort -n -r"

As a standard command, we issue ssh ubu1
and then put our command to run remotely.
作为标准命令,我们发布ssh ubu1
,然后将我们的命令远程运行。
linux磁盘空间