Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use df Command in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use df command in Linux system". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use the df command in the Linux system".

Df is the "available disk" disk free, which is used to display the disk usage of the file system. By default, the df command will display all currently mounted file systems in 1K units per block. If you want to display the output of the df command in a human-readable format, use the-h option like this "df-h".

In this article, we will discuss 11 different examples of df commands under Linux.

The basic format of the df command under Linux is:

The code is as follows:

# df {options} {mount_point_of_filesystem}

The options available in the df command are:

Sample output of df:

The code is as follows:

[root@linux-world ~] # df

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/mapper/vg00-root 17003304 804668 15311852 5% /

Devtmpfs 771876 0 771876 / dev

Tmpfs 777928 0 777928 / dev/shm

Tmpfs 777928 8532 769396 2% / run

Tmpfs 777928 0 777928 / sys/fs/cgroup

/ dev/mapper/vg00-home 14987616 41000 14162232 1% / home

/ dev/sda1 487652 62593 395363 14% / boot

/ dev/mapper/vg00-var 9948012 48692 9370936 1% / var

/ dev/mapper/vg00-sap 14987656 37636 14165636 1% / sap

[root@linux-world ~] #

Example 1: use the-an option to list the disk usage of all file systems

When we use the-an option in the df command, it shows disk usage for all file systems.

The code is as follows:

[root@linux-world] # df-a

Filesystem 1K-blocks Used Available Use% Mounted on

Rootfs 17003304 804668 15311852 5 per cent

Proc 0 000-/ proc

Sysfs 0 000-/ sys

Devtmpfs 771876 0 771876 / dev

Securityfs 0 000-/ sys/kernel/security

Tmpfs 777928 0 777928 / dev/shm

Devpts 0 000-/ dev/pts

Tmpfs 777928 8532 769396 2% / run

Tmpfs 777928 0 777928 / sys/fs/cgroup

Cgroup 0 000-/ sys/fs/cgroup/systemd

Pstore 0 000-/ sys/fs/pstore

Cgroup 0 000-/ sys/fs/cgroup/cpuset

Cgroup 0 000-/ sys/fs/cgroup/cpu,cpuacct

Cgroup 0 000-/ sys/fs/cgroup/memory

Cgroup 0 000-/ sys/fs/cgroup/devices

Cgroup 0 000-/ sys/fs/cgroup/freezer

Cgroup 0 000-/ sys/fs/cgroup/net_cls

Cgroup 0 000-/ sys/fs/cgroup/blkio

Cgroup 0 000-/ sys/fs/cgroup/perf_event

Cgroup 0 000-/ sys/fs/cgroup/hugetlb

Configfs 0 000-/ sys/kernel/config

/ dev/mapper/vg00-root 17003304 804668 15311852 5% /

Selinuxfs 0 000-/ sys/fs/selinux

Systemd-1 0 000-/ proc/sys/fs/binfmt_misc

Debugfs 0 000-/ sys/kernel/debug

Hugetlbfs 0 000-/ dev/hugepages

Mqueue 0 000-/ dev/mqueue

/ dev/mapper/vg00-home 14987616 41000 14162232 1% / home

/ dev/sda1 487652 62593 395363 14% / boot

/ dev/mapper/vg00-var 9948012 48692 9370936 1% / var

/ dev/mapper/vg00-sap 14987656 37636 14165636 1% / sap

[root@linux-world ~] #

Example 2: display the output of the df command in a human-readable format

Use the-h option in the df command to output in a format that is easy for humans to read (for example, 5KMagne500m and 5G)

The code is as follows:

[root@linux-world] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/vg00-root 17G 786M 15G 5% /

Devtmpfs 754M 0 754m 0% / dev

Tmpfs 760M 0 760M 0% / dev/shm

Tmpfs 760M 8.4m 752m 2% / run

Tmpfs 760M 0 760M 0% / sys/fs/cgroup

/ dev/mapper/vg00-home 15G 41m 14G 1% / home

/ dev/sda1 477M 62m 387M 14% / boot

/ dev/mapper/vg00-var 9.5G 48m 9.0G 1% / var

/ dev/mapper/vg00-sap 15G 37M 14G 1% / sap

[root@linux-world ~] #

Example 3: display the space used by a specific file system

If we want to show the usage of / sap filesystem space.

The code is as follows:

[root@linux-world] # df-h / sap/

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/vg00-sap 15G 37M 14G 1% / sap

[root@linux-world ~] #

Example 4: output the types of all mounted file systems

The-T option is used in the df command to display the type of file system.

The code is as follows:

[root@linux-world] # df-T

Filesystem Type 1K-blocks Used Available Use% Mounted on

/ dev/mapper/vg00-root ext4 17003304 804668 15311852 5% /

Devtmpfs devtmpfs 771876 0 771876 / dev

Tmpfs tmpfs 777928 0 777928 / dev/shm

Tmpfs tmpfs 777928 8532 769396 2% / run

Tmpfs tmpfs 777928 0 777928 / sys/fs/cgroup

/ dev/mapper/vg00-home ext4 14987616 41000 14162232 1% / home

/ dev/sda1 ext3 487652 62593 395363 14% / boot

/ dev/mapper/vg00-var ext3 9948012 48696 9370932 1% / var

/ dev/mapper/vg00-sap ext3 14987656 37636 14165636 1% / sap

[root@linux-world ~] #

Example 5: output file system disk usage by block size

The code is as follows:

[root@linux-world] # df-k

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/mapper/vg00-root 17003304 804668 15311852 5% /

Devtmpfs 771876 0 771876 / dev

Tmpfs 777928 0 777928 / dev/shm

Tmpfs 777928 8532 769396 2% / run

Tmpfs 777928 0 777928 / sys/fs/cgroup

/ dev/mapper/vg00-home 14987616 41000 14162232 1% / home

/ dev/sda1 487652 62593 395363 14% / boot

/ dev/mapper/vg00-var 9948012 48696 9370932 1% / var

/ dev/mapper/vg00-sap 14987656 37636 14165636 1% / sap

[root@linux-world ~] #

Example 6: output inode information of a file system

The-I option is used in the df command to display inode information for the file system.

Inode information for all file systems:

The code is as follows:

[root@linux-world] # df-I

Filesystem Inodes IUsed IFree IUse% Mounted on

/ dev/mapper/vg00-root 1089536 22031 1067505 3%

Devtmpfs 192969 357 192612 / dev

Tmpfs 194482 1 194481 1 per dev/shm

Tmpfs 194482 420 194062 / run

Tmpfs 194482 13 194469 1% / sys/fs/cgroup

/ dev/mapper/vg00-home 960992 15 960977 / home

/ dev/sda1 128016 337 127679 / boot

/ dev/mapper/vg00-var 640848 1235 639613 1% / var

/ dev/mapper/vg00-sap 960992 11 960981 / sap

[root@linux-world ~] #

Inode information for a specific file system:

The code is as follows:

[root@linux-world] # df-I / sap/

Filesystem Inodes IUsed IFree IUse% Mounted on

/ dev/mapper/vg00-sap 960992 11 960981 / sap

[root@linux-world ~] #

Example 7: output a summary of all file system usage

The-total option is used in the df command to display a summary of disk usage for all file systems.

The code is as follows:

[root@linux-world] # df-h-- total

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/vg00-root 17G 786M 15G 5% /

Devtmpfs 754M 0 754m 0% / dev

Tmpfs 760M 0 760M 0% / dev/shm

Tmpfs 760M 8.4m 752m 2% / run

Tmpfs 760M 0 760M 0% / sys/fs/cgroup

/ dev/mapper/vg00-home 15G 41m 14G 1% / home

/ dev/sda1 477M 62m 387M 14% / boot

/ dev/mapper/vg00-var 9.5G 48m 9.0G 1% / var

/ dev/mapper/vg00-sap 15G 37M 14G 1% / sap

Total 58G 980m 54G 2%-

[root@linux-world ~] #

Example 8: print only the use of local file system disks

Suppose the network file system is also mounted on Linux, but we only want to display information about the local file system, which can be done by using the-l option of the df command.

Print only the local file system:

The code is as follows:

[root@linux-world ~] # df-Thl

Filesystem Type Size Used Avail Use% Mounted on

/ dev/mapper/vg00-root ext4 17G 791M 15G 6% /

Devtmpfs devtmpfs 754M 0 754m 0% / dev

Tmpfs tmpfs 760M 0 760M 0% / dev/shm

Tmpfs tmpfs 760M 8.4m 752m 2% / run

Tmpfs tmpfs 760M 0 760M 0% / sys/fs/cgroup

/ dev/mapper/vg00-home ext4 15G 41m 14G 1% / home

/ dev/sda1 ext3 477M 62m 387M 14% / boot

/ dev/mapper/vg00-var ext3 9.5G 105m 8.9G 2% / var

/ dev/mapper/vg00-sap ext3 15G 37M 14G 1% / sap

[root@linux-world ~] #

Example 9: print disk usage for a specific file system type

The-t option is used in the df command to print information about a specific file system type, specifying the file system type with-t, as follows:

For ext4:

The code is as follows:

[root@linux-world] # df-t ext4

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/mapper/vg00-root 17003304 809492 15307028 6 /

/ dev/mapper/vg00-home 14987616 41000 14162232 1% / home

[root@linux-world ~] #

For nfs4:

The code is as follows:

[root@linux-world] # df-t nfs4

Filesystem 1K-blocks Used Available Use% Mounted on

192.168.1.5:/opensuse 301545472 266833920 19371008 94% / data

[root@linux-world ~] #

Example 10: use the-x option to exclude specific file system types

-x or-exclude-type is used in the df command to expel certain file system types in the output.

Suppose we want to print all the file systems except ext3.

The code is as follows:

[root@linux-world ~] # df-x ext3

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/mapper/vg00-root 17003304 809492 15307028 6 /

Devtmpfs 771876 0 771876 / dev

Tmpfs 777928 0 777928 / dev/shm

Tmpfs 777928 8540 769388 2% / run

Tmpfs 777928 0 777928 / sys/fs/cgroup

/ dev/mapper/vg00-home 14987616 41000 14162232 1% / home

192.168.1.5:/opensuse 301545472 266834944 19369984 94% / data

[root@linux-world ~] #

Example 11: only specific fields are printed in the output of the df command

The-output= {field_name1,field_name2...} option is used to display the output of some fields of the df command.

Available field names are: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent and target

The code is as follows:

[root@linux-world] # df-- output=fstype,size,iused

Type 1K-blocks IUsed

Ext4 17003304 22275

Devtmpfs 771876 357

Tmpfs 777928 1

Tmpfs 777928 423

Tmpfs 777928 13

Ext4 14987616 15

Ext3 487652 337

Ext3 9948012 1373

Ext3 14987656 11

Nfs4 301545472 451099

[root@linux-world ~] #

At this point, I believe you have a deeper understanding of "the use of df commands in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report