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 under linux system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you "how to use the df command under the linux system", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the df command under the linux system" this article.

Df command parameter function in linux: check the disk space consumption of the file system. You can use this command to get information such as how much space the hard disk is occupied and how much space is left.

Syntax: df [options]

Description: the df command in linux displays the usage of I nodes and disk blocks by all file systems.

The meanings of the options for this command are as follows:

"- a displays the disk usage of all file systems, including 0 (block) file systems, such as / proc file systems."

-k is displayed in k bytes.

"- I displays I node information, not disk blocks."

-t displays the disk space usage of each specified type of file system.

-x lists disk space usage that is not a specified type of file system (as opposed to the t option).

-T displays the file system type.

Function: check the disk space usage of the file system. You can use this command to get information such as how much space the hard disk is occupied and how much space is left.

Syntax: df [options]

Description: the df command in linux displays the usage of I nodes and disk blocks by all file systems.

Description: the meaning of each option of the df command in linux is as follows:

-an or-- all: contains all file systems

-- block-size=: displays the number of blocks at the specified block size

-h or-- human-readable: displays information in a highly readable manner

-H or-- si: same as the-h parameter, but calculated in 1000 Bytes instead of 1024 Bytes

-I or-- inodes: displays information about inode

-k or-- kilobytes: specify a chunk size of 1024 bytes

-l or-- local: show only local-side file systems

-m or-- megabytes: specify a chunk size of 1048576 bytes

-- no-sync: do not execute the sync instruction before getting the disk usage information. This is the default value.

-P or-- portability: use the output format of POSIX

-- sync: execute the sync instruction before getting disk usage information

-t or-- type=: displays only disk information of the specified file system type

-T or-- print-type: displays the type of file system

-x or-- exclude-type=: do not display disk information of the specified file system type

-- help: show help

-- version: displays version information.

Example 1: list the disk space usage of each file system.

$df

Filesystem 1 K-blocks Used Available Use% Mounted on

/ dev/hda2 1361587 1246406 44823 97 /

The first column of the output list of the df command in linux is the pathname of the device file corresponding to the file system (usually the partition on the hard disk); the second column shows the number of data blocks (1024 bytes) contained in the partition; and the third and fourth columns represent the number of used and available data blocks, respectively. Users may find it strange that the sum of the number of blocks in column 3 and 4 is not equal to the number of blocks in column 2. This is because each partition by default leaves a small amount of space for the system administrator to use. Even if the normal user space is full, the administrator can still log in and leave the workspace needed to solve the problem. The Use% column in the list represents the percentage of normal user space used, and even if this number reaches 100%, the partition still has space for the system administrator. Finally, the Mounted on column represents the mount point of the file system.

Example 2: list the I node usage of each file system.

$df-ia

Filesystem Inodes IUsed IFree Iused% Mounted on

/ dev/ hda2 352256 75043 277213 21% /

None 0 000 0% / proc

Localhost: (pid221) 0 000 0% / net

Example 3: lists the types of file systems.

$df-T

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

/ dev/hda2 ext2 1361587 1246405 44824 97 /

The file system in this example is of type ext2

[root@rac1 ~] # df

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/sda1 3020140 2333952 532772 82%

None 213320 0 213320 / dev/shm

/ dev/sda2 4633108 1818088 2579668 42% / U01

/ dev/sde1 524272 81104 443168 16% / ocfs

This command shows the usage of all partitions on the server. It also includes several useful parameters to help format the output:

-a shows all the partitions of the system, but does not show 0 blocks by default.

[root@rac1] # df-a

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/sda1 3020140 2333952 532772 82%

None 0 000-/ proc

None 0 000-/ sys

None 0 000-/ dev/pts

None 213320 0 213320 / dev/shm

/ dev/sda2 4633108 1818096 2579660 42% / U01

None 0 000-/ proc/sys/fs/binfmt_misc

Sunrpc 0 000-/ var/lib/nfs/rpc_pipefs

Configfs 0 000-/ config

Ocfs2_dlmfs 0 000-/ dlm

/ dev/sde1 524272 81104 443168 16% / ocfs

Oracleasmfs 0 000-/ dev/oracleasm

-h more current disk space and usage are displayed in a more readable manner

[root@rac1] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/sda1 2.9G 2.3G 521M 82% /

None 209m 0 209m 0% / dev/shm

/ dev/sda2 4.5G 1.8G 2.5G 42% / U01

/ dev/sde1 512M 80M 433M 16% / ocfs

The-h parameter above the-H root is the same, but when rooting, use 1000 instead of 1024 for capacity conversion

[root@rac1] # df-H

Filesystem Size Used Avail Use% Mounted on

/ dev/sda1 3.1G 2.4G 546m 82% /

None 219m 0 219m 0% / dev/shm

/ dev/sda2 4.8G 1.9G 2.7G 42% / U01

/ dev/sde1 537M 84M 454M 16% / ocfs

-k displays disk usage in units

[root@rac1] # df-k

Filesystem 1K-blocks Used Available Use% Mounted on

/ dev/sda1 3020140 2333952 532772 82%

None 213320 0 213320 / dev/shm

/ dev/sda2 4633108 1818152 2579604 42% / U01

/ dev/sde1 524272 81104 443168 16% / ocfs

-l shows the disk space utilization of the local partition. If the server nfs the disk of the remote server, then add-l to the df and the system displays the result after filtering the nsf drive.

-I shows the usage of inode. Linux uses a pointer-like way to manage disk space mapping. This is also a key application.

Example

View the system disk devices. The default is KB:

Bash/shell Code copies content to the clipboard

[root@LinServ-1 ~] # df

File system 1K-Block used available used% mount point

/ dev/sda2 146294492 28244432 110498708 21% /

/ dev/sda1 1019208 62360 904240 7% / boot

Tmpfs 1032204 0 1032204 / dev/shm

/ dev/sdb1 2884284108 218826068 2518944764 8% / data1

Use the-h option to display in units above KB, with high readability:

Bash/shell Code copies content to the clipboard

[root@LinServ-1] # df-h

File system capacity used available used% mount point

/ dev/sda2 140G 27G 106G 21% /

/ dev/sda1 996M 61m 884M 7% / boot

Tmpfs 1009M 0 1009M 0% / dev/shm

/ dev/sdb1 2.7T 209G 2.4T 8% / data1

View all file systems:

Bash/shell Code copies content to the clipboard

[root@LinServ-1] # df-a

File system 1K-Block used available used% mount point

/ dev/sda2 146294492 28244432 110498708 21% /

Proc 0 000-/ proc

Sysfs 0 000-/ sys

Devpts 0 000-/ dev/pts

/ dev/sda1 1019208 62360 904240 7% / boot

Tmpfs 1032204 0 1032204 / dev/shm

/ dev/sdb1 2884284108 218826068 2518944764 8% / data1

None 0 000-/ proc/sys/fs/binfmt_misc

The above is all the contents of the article "how to use df commands in linux system". 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

Servers

Wechat

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

12
Report