专业的编程技术博客社区

网站首页 > 博客文章 正文

linux 命令行之你真的会用吗?--df 基本用法

baijin 2024-09-14 00:07:25 博客文章 6 ℃ 0 评论

df 基本用法

这里d指disk,f代表filesystem文件系统,df 计算出文件系统占用磁盘的比例数据,也可以显示文件索引块inode相关信息。

这节主要分享-a/-h/-k/-T/-t/-x参数,以及其组合用法。

  • -a, --all include dummy file systems

显示所有文件系统的占用数据,包括虚假文件系统。

  • --total produce a grand total

在末尾增加一个total统计,便于查看。

lance@ubuntu:~/cmd/free$ df --total

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda1 9156984 2800184 5868608 33% /

udev 503124 4 503120 1% /dev

tmpfs 102524 788 101736 1% /run

none 5120 0 5120 0% /run/lock

none 512604 200 512404 1% /run/shm

total 10280356 2801176 6990988 29%

  • -h, --human-readable print sizes in human readable format

按方便阅读的单位显示,即当占用达到Kbyte时,用KB作为显示代为,如果达到M,则按照MB统计,以此类推试用G、T等更大的单位。

lance@ubuntu:~/cmd/free$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 8.8G 2.7G 5.6G 33% /
udev 492M 4.0K 492M 1% /dev
tmpfs 101M 788K 100M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 501M 200K 501M 1% /run/shm

  • -k like --block-size=1K

按KB单位统计。

lance@ubuntu:~/cmd/free$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 9156984 2800188 5868604 33% /
udev 503124 4 503120 1% /dev
tmpfs 102524 788 101736 1% /run
none 5120 0 5120 0% /run/lock
none 512604 200 512404 1% /run/shm

  • -T, --print-type print file system type

显示文件系统类型,这个参数很有用,增加Type列,列出文件系统的具体类型。

lance@ubuntu:~/cmd/free$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 9156984 2800188 5868604 33% /
udev devtmpfs 503124 4 503120 1% /dev
tmpfs tmpfs 102524 788 101736 1% /run
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 512604 200 512404 1% /run/shm

  • -t, --type=TYPE limit listing to file systems of type TYPE

配合-T参数使用,只显示指定类型的文件系统,比如只显示ext4的占用比。

lance@ubuntu:~/cmd/free$ df -t ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 9156984 2800188 5868604 33% /

lance@ubuntu:~/cmd/free$ df --type=ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 9156984 2800188 5868604 33% /

  • -x, --exclude-type=TYPE limit listing to file systems not of type TYPE

和-t作用正好相反,不查看指定类型的文件系统,比如不查看ext4的信息。

lance@ubuntu:~/cmd/free$ df -x ext4
Filesystem 1K-blocks Used Available Use% Mounted on
udev 503124 4 503120 1% /dev
tmpfs 102524 788 101736 1% /run
none 5120 0 5120 0% /run/lock
none 512604 200 512404 1% /run/shm

lance@ubuntu:~/cmd/free$ df --exclude-type=ext4
Filesystem 1K-blocks Used Available Use% Mounted on
udev 503124 4 503120 1% /dev
tmpfs 102524 788 101736 1% /run
none 5120 0 5120 0% /run/lock
none 512604 200 512404 1% /run/shm

更详细清楚讲解请观看西瓜视频讲解:

西瓜linux命令行du基本用法视频讲解

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表