一、df命令

df 命令用来查看各个磁盘占用空间大小,默认以字节为单位,可以添加-h 选项以合适的单位显示。

[ma@ma ~]$ df
Filesystem        1K-blocks     Used    Available Use% Mounted on
/dev/vda1          41151808  5702332     33352428  15% /
tmpfs                961040        0       961040   0% /dev/shm
/dev/vdb1          20511244 12006916      7455760  62% /data
/dev/vdc1          20511244    82052     19380624   1% /disk1
ossfs          274877906944        0 274877906944   0% /ossdata
[ma@ma ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  5.5G   32G  15% /
tmpfs           939M     0  939M   0% /dev/shm
/dev/vdb1        20G   12G  7.2G  62% /data
/dev/vdc1        20G   81M   19G   1% /disk1
ossfs           256T     0  256T   0% /ossdata

二、du命令

du 命令用来统计文件大小,-h 选项以合适单位显示,-s 选项显示总计可以统计文件夹大小:

[ma@ma test]$ du -h
8.0K    ./.git/info
4.0K    ./.git/branches
4.0K    ./.git/refs/tags
8.0K    ./.git/refs/remotes/origin
12K    ./.git/refs/remotes
8.0K    ./.git/refs/heads
28K    ./.git/refs
4.0K    ./.git/objects/info
8.0K    ./.git/objects/f0
4.0K    ./.git/objects/pack
8.0K    ./.git/objects/03
8.0K    ./.git/objects/69
36K    ./.git/objects
48K    ./.git/hooks
8.0K    ./.git/logs/refs/remotes/origin
12K    ./.git/logs/refs/remotes
8.0K    ./.git/logs/refs/heads
24K    ./.git/logs/refs
32K    ./.git/logs
180K    ./.git
12K    ./test
204K    .
[ma@ma test]$ du -hs  # 统计所有文件的总计大小
204K    .

可以使用du -hs * 分别统计各个文件和文件夹的大小:

[ma@ma test]$ tree
.
├── 2.md
├── README.md
└── test
    ├── 2.md
    └── README.md

1 directory, 4 files
[ma@ma test]$ du -sh * # 统计各个文件个文件夹大小
4.0K    2.md
4.0K    README.md
12K    test
最后修改:2018 年 03 月 02 日
如果觉得我的文章对你有用,请随意赞赏