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 the common command df in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use the Linux command df, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux common command df (English full spelling: disk free) command is used to display file system disk usage statistics currently on Linux systems.

Syntax df [options]... [FILE]... File-a,-all contains all file systems with 0 Blocks

File-block-size= {SIZE} uses a Blocks of {SIZE} size

The file-h,-human-readable uses a human-readable format (the default value is not added with this option.)

The file-H,-si is very similar to-h, but in units of 1000 instead of 1024

File-I,-inodes lists inode information, but does not list block used

The file-k,-kilobytes is like-block-size=1024

File-l,-local limits the file structure listed

The file-m,-megabytes is like-block-size=1048576

File-do not sync before no-sync gets the information (default)

File-P,-portability uses the POSIX output format

Document-sync sync before obtaining information

File-t,-type=TYPE limit the TYPE of the file system

File-T,-print-type shows the form of the file system

File-x,-exclude-type=TYPE restrict listing file systems do not display TYPE

File-v (ignore)

File-help shows this helper and leaves

File-version outputs version information and leaves

Example 1: using the-an option to list the disk usage of all file systems when we use the-an option in the df command, it shows the disk usage of all file systems.

[root@linux-world ~] # df-a Filesystem 1K-blocks Used Available Use% Mounted on rootfs 17003304 804668 / proc 15311852-/ proc sysfs 00-/ sys devtmpfs 771876 0 771876 15311852 / dev securityfs 0 777928-/ sys/kernel/security tmpfs 777928 0 0 0 / dev/shm devpts 0 0-/ dev/pts tmpfs 777928 8532 769396 2% / run tmpfs 777928 0 777928 / sys/fs/cgroup cgroup 0 0-/ sys/fs/cgroup/systemd pstore 0 0-/ sys/fs/pstore cgroup 0 0-/ sys/fs/cgroup/cpuset cgroup 0 000-/ sys/fs/cgroup/cpu Cpuacct cgroup 0 0-/ sys/fs/cgroup/memory cgroup 0 0-/ sys/fs/cgroup/devices cgroup 0 0-/ sys/fs/cgroup/freezer cgroup 0 0 0-/ sys/fs/cgroup/net_cls cgroup 000-/ sys/fs/cgroup/blkio cgroup 000-/ sys/fs/cgroup/perf_event cgroup 000-/ sys/fs/cgroup/hugetlb configfs 15311852-/ sys/kernel/config / dev/mapper/vg00-root 17003304 804668 5% / selinuxfs 000-/ sys/fs/selinux systemd-1 000-/ proc/sys/fs/binfmt_misc debugfs Dev/mqueue / dev/mapper/vg00-home 14987616 41000 14162232 1 per cent / home / dev/sda1 487652 62593 395363 14% / boot / dev/mapper/vg00- Var 9948012 48692 9370936 1% / var / dev/mapper/vg00-sap 14987656 37636 141656361% / sap [root@linux-world ~] # example 2: display the output of the df command in a human readable format using the-h option in the df command Output in a format that is easy for humans to read (for example, 5KJE 500m and 5G)

We want to show the usage of / sap filesystem space.

[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 type of all mounted file systems-T option is used to display the type of file system in the df command.

Root@linux-world ~] # df-T Filesystem Type 1K-blocks Used Available Use% Mounted on / dev/mapper/vg00-root ext4 17003304 804668 15311852 / devtmpfs devtmpfs 771876 0771876% / devtmpfs tmpfs 777928 07779280% / dev/shm tmpfs tmpfs 7779288532 769396% / 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 93709331% / var / dev/mapper/vg00-sap ext3 14987656 37636 141656361% / 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 / devtmpfs 771876 0771876% / devtmpfs 777928 0777928 0% / dev/shm tmpfs 777928 8532 769396 / run tmpfs 777928 0 777928 / sys/fs/cgroup / dev/mapper/vg00-home 14987616 41000 14162232% / home / dev/sda1 487652 62593 395363 14% / boot / dev/mapper/vg00-var 9948012 48696 93709331% / var / dev/mapper/vg00-sap 14987656 37636 141656361 / sap [root@linux-world ~] example 6: output inode information of the file system-I option is used in the df command to display the inode information of 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 / devtmpfs 192969 357 192612 1 / devtmpfs 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 per cent / home / dev/sda1 128016 337 127679 1 per cent / boot / dev/mapper/vg00-var 640848 1235 6396131 per cent / var / dev/mapper/vg00-sap 960992 11 9609881 per cent / sap [root@linux-world] # inode information for a specific file system:

[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: export a summary of all file system usage-the total option is used to display a summary of disk usage for all file systems in the df command.

[root@linux-world] # df-h-- total Filesystem Size Used Avail Use% Mounted on / dev/mapper/vg00-root 17G 786M 15G 5% / devtmpfs 754M 0754M 0% / devtmpfs 760M 0760M 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 assuming that 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:

[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 0754M 0% / devtmpfs tmpfs 760M 0760M 0% / dev/shm tmpfs tmpfs 760M 8.4m 752m 2% / run tmpfs Tmpfs 760M 0760M 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 of a specific file system type-t option is used to print information of a specific file system type in the df command Specify 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 nfs4Filesystem 1K-blocks Used Available Use% Mounted on192.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 exclude certain file system types in the output.

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

[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] # these are all the contents of this article entitled "how to use df with Linux commands". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report