Linux df 查看磁盘空间使用量 du 查看指定目录/文件的大小

https://blog.csdn.net/wuyujin1997/article/details/105322428/

 

查看磁盘空间使用量
df -h

wuyujin@ubuntu18:~/Desktop/text$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 5.8G 0 5.8G 0% /dev
tmpfs 1.2G 2.1M 1.2G 1% /run
/dev/sda2 457G 61G 373G 15% /
... 此处省略多行信息
wuyujin@ubuntu18:~/Desktop/text$

1
2
3
4
5
6
7
8
会列出多个字段:
Filesystem Size Used Avail Use% Mounted on
文件系统 大小 已使用 未使用 已使用的百分比 挂载点
根据以上执行过程中的/dev/sda2 457G 61G 373G 15% /这一行,可以知道:
我的硬盘有457GB大小,已经使用了61G,剩余373GB未使用。

查看指定目录大小
查看指定目录 du -h 目录路径
查看指定文件 du -h 文件名
如:

wuyujin@ubuntu18:~/Desktop/text$ du -h .
12K .
wuyujin@ubuntu18:~/Desktop/text$
wuyujin@ubuntu18:~/Desktop/text$ du -h *
4.0K CSDN.md
4.0K tmp.md
wuyujin@ubuntu18:~/Desktop/text$ du -h CSDN.md
4.0K CSDN.md
wuyujin@ubuntu18:~/Desktop/text$
1
2
3
4
5
6
7
8
9
Intro
df和du是做什么的?-h选项又是什么意思?

wuyujin@ubuntu18:~/Desktop/text$ whatis df
df (1) - report file system disk space usage
wuyujin@ubuntu18:~/Desktop/text$ whatis du
du (1) - estimate file space usage
wuyujin@ubuntu18:~/Desktop/text$
wuyujin@ubuntu18:~/Desktop/text$ df --help | grep " \-h"
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
wuyujin@ubuntu18:~/Desktop/text$ du --help | grep " \-h"
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
--si like -h, but use powers of 1000 not 1024
wuyujin@ubuntu18:~/Desktop/text$
1
2
3
4
5
6
7
8
9
10
11
可见:
- df: 用于查看文件系统的磁盘空间使用量。
- du: 估算文件的大小/空间使用情况。
- -h: 即human-readable,人类可读,会显示文件的大小为易读的xxM,XXG等格式。
————————————————
版权声明:本文为CSDN博主「锦天」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wuyujin1997/article/details/105322428/

posted @ 2022-02-11 16:51  China Soft  阅读(421)  评论(0编辑  收藏  举报