发表于: lnmp | 作者: | 日期: 2014/4/10 09:04

今天也有同学问我Linux下查看目录大小的命令,现在也将前阵子学习到du/df两个命令总结一下吧。
前阵子测试工作中有遇到过由于磁盘空间满导致程序无法执行到情况,所以使用了df和du两个命令。
du查看目录大小,df查看磁盘使用情况。
我常使用的命令(必要时,sudo使用root权限),
1.查看某个目录的大小:du -hs /home/master/documents
查看目录下所有目录的大小并按大小降序排列:sudo du -sm /etc/* | sort -nr | less
2.查看磁盘使用情况(文件系统的使用情况):sudo df -h
df –block-size=GB
-h是使输出结果更易于人类阅读;du -s只展示目录的使用总量(不分别展示各个子目录情况),-m是以MB为单位展示目录的大小(当然-k/-g就是KB/GB了)。
更多信息,还是man du 和 man df 来获得吧。
du – estimate file space usage
Summarize disk usage of each FILE, recursively for directories.
df – report file system disk space usage
Show information about the file system on which each FILE resides, or all file systems by default.
df displays the amount of disk space available on the file system containing each file nameargument. If no file name is given, the space available on all currently mounted file systems is shown.
[来源:http://www.51testing.com/?uid-225738-action-viewspace-itemid-208965]

: https://blog.darkmi.com/2014/04/10/3757.html

本文相关评论 - 1条评论都没有呢
Post a comment now » 本文目前不可评论

No comments yet.

Sorry, the comment form is closed at this time.