Example detailed linxu df command _linux Shell

Source: Internet
Author: User
Tags readable disk usage

DF, free disk, is used to display the disk usage of the file system. By default, the DF command will display all currently mounted file systems in each 1K unit, if you want to display the output of the DF command in a human readable format, such as "df-h" using the-H option.

In this article, we will discuss 11 different instances of the DF command under Linux.

The basic format of the DF command under Linux is:

Copy Code code as follows:

# DF {options} {Mount_point_of_filesystem}

The options available in the DF command are:

Sample output of DF:

[Root@linux-world ~]
# DF
filesystem 1k-blocks Used Available use% mounted on/dev/mapper/vg00-root 17003304 804668 15311852 5%
/
D Evtmpfs 771876 0 771876 0%/dev
tmpfs 777928 0 777928 0%/dev/shm tmpfs 777928 8532 769396 2%/run tmpfs
77792 8 0 777928 0%/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% /s AP
[Root@linux-world ~]
#

Example 1: Use the-a option to list the amount of disk usage for all file systems

When we use the-a option in the DF command, it displays the disk usage of all file systems.

[Root@linux-world ~] # df-a filesystem 1k-blocks Used Available use% mounted ' on Rootfs 17003304 804668 15311852 5%/Pro  C 0 0 0-//proc SYSFS 0 0 0-/sys devtmpfs 771876 0 771876 0%/dev SECURITYFS 0 0 0-/sys/kernel/security tmpfs 777928 0 777928 0%/dev/shm devpts 0 0 0-/dev/pts tmpfs 777928 8532 769396 2%/run tmpfs 777928 0 777928 0%/sys/fs/cgroup Cgrou P 0 0 0-/sys/fs/cgroup/systemd pstore 0 0 0-/sys/fs/pstore cgroup 0 0 0-/sys/fs/cgroup/cpuset cgroup 0 0 0-/sys/fs /cgroup/cpu,cpuacct Cgroup 0 0 0-/sys/fs/cgroup/memory cgroup 0 0 0-/sys/fs/cgroup/devices cgroup 0 0 0-/sys/fs/cgro Up/freezer Cgroup 0 0 0-/sys/fs/cgroup/net_cls cgroup 0 0 0-/sys/fs/cgroup/blkio cgroup 0 0 0-/sys/fs/cgroup/perf_ev Ent cgroup 0 0 0-/sys/fs/cgroup/hugetlb Configfs 0 0 0-/sys/kernel/config/dev/mapper/vg00-root 17003304 804668 153118 5%/SELINUXFS 0 0 0-/sys/fs/selinux systemd-1 0 0 0-/proc/sys/fs/binfmt_misc Debugfs 0 0 0-/sys/kernel/debug hug ETLBFS 0 0 0-/dev/hugePages Mqueue 0 0 0-/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: Displaying the output of the DF command in a human readable format

Use the-H option in the DF command to output in a human readable format (e.g., 5k,500m and 5G)

[Root@linux-world ~]
# df-h
filesystem Size Used avail use% mounted on
/dev/mapper/vg00-root 17G 786M 15G 5%/
devtmpfs 754M 0 754 M 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: Show the space used by a particular file system

If we want to show the use of/SAP file system space.

[Root@linux-world ~]
# df-h/sap/
filesystem Size Used avail use% mounted on
/dev/mapper/vg00-sap 15G 37M 14G 1%/sap
[Root@lin Ux-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.

[Root@linux-world ~]
# df-t
filesystem Type 1k-blocks Used Available use% mounted on
/dev/mapper/vg00-root ext4 17003304 804668 153118 5%/
Devtmpfs devtmpfs 771876 0 771876 0% Dev
tmpfs tmpfs 777928 0 777928 0%/dev/shm
tmpfs tmpfs 777928 8 532 769396 2%/run
tmpfs tmpfs 777928 0 777928 0%/sys/fs/cgroup/dev/mapper/vg00-home ext4
14987616 41000 1416223 2 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

[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 0%/dev
tmpfs 777928 0 777928 0%/dev/shm tmpfs 777928 8532 769396 2%/run tmpfs
77 7928 0 777928 0%/sys/fs/cgroup/dev/mapper/vg00-home 14987616 41000 14162232 1%/home/dev/sda1
487652 62593 3953  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 the Inode information for the file system

The-i option is used in the DF command to display the Inode information for the file system.

Inode information for all file systems:

[Root@linux-world ~]
# df-i
filesystem inodes iused ifree iuse% mounted on
/dev/mapper/vg00-root 1089536 22031 1067505 3%/
devtmp  FS 192969 357 192612 1%/dev
tmpfs 194482 1 194481 1%/dev/shm tmpfs 194482 420 194062 1%/run tmpfs
194482 13 194469 1% /sys/fs/cgroup
/dev/mapper/vg00-home 960992 15 960977 1% /home
/dev/sda1 128016 337 127679 1% /boot
   /dev/mapper/vg00-var 640848 1235 639613 1%/var/dev/mapper/vg00-sap 960992-960981
1%/SAP
[ Root@linux-world ~]
#

Inode information for a particular file system:

[Root@linux-world ~]
# df-i/sap/
filesystem inodes iused ifree iuse% mounted on
/dev/mapper/vg00-sap 960992 one 960981
1%/sap [Root@linux-world ~]
#

Example 7: Output 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.

[Root@linux-world ~]
# df-h--total
filesystem Size Used avail use% mounted on
/dev/mapper/vg00-root 17G 786M 15G 5%/
DEVTMPFS 75 4M 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/cgro  Up
/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 achieved by using the-l option of the DF command.

Print only local file systems:

[Root@linux-world ~]
# DF-THL
filesystem Type Size Used avail use% mounted on
/dev/mapper/vg00-root ext4 17G 791M 15G 6%/
Devtmpf s DEVTMPFS 754M 0 754M 0%/dev
tmpfs tmpfs 760M 0 760M 0%/dev/shm tmpfs
tmpfs 760M 8.4M 752M 2%/run TMPFS
TM  PFS 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 particular file system type, specifying the type of file system with-T, as follows:

For EXT4:

[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:

[Root@linux-world ~]
# df-t NFS4
filesystem 1k-blocks Used Available use% mounted on
192.168.1.5:/opensuse 301545472 266833920 1937100 8 94%/data
[Root@linux-world ~]
#

Example 10: Using 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 from the output.

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

[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 0%/dev
tmpfs 777928 0 777928 0%/dev/shm tmpfs
777928 8540 769388 2%/run
   tmpfs 777928 0 777928 0%/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

-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

[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 ext4 14987616 ext3 487652 337 ext3 9948012
ex T3 14987656
nfs4 301545472 451099
[Root@linux-world ~]
#
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.