Linux view folder size, remaining disk space (DU / DF)

1. Introduction

du for directory size, df for disk usage.

2. du

disk usage
(1) basic function
recursively view the sizes of all files under the folder
(2) common parameters:
-h, — human-readable for size (for example: 1K 234M 2G)
-s, — summarize each parameter in the command column calculated the total amount of
(3) other parameters:
-a, — all output the disk amount of all files, not just the directory
— summary size display surface amount, but not the disk amount; Although the surface usage is usually smaller, it can sometimes become larger due to “holes” between sparse files, internal fragments, blocks that are not directly referenced, and so on.
-b, — block-size=
-b, — bytes = — br>-size =1
-c, — total display total information
-d, The filename ending in NUL in the calculated file F corresponds to the space on the disk. If the value of F is “-“, then the filename read from the standard input
-h is equal to — dereference-args (-d)
-h. The — human-readable sizes are displayed in a readable manner (for example, 1K 234M 2G)
— si similar to -h, but using 1000 as the basis for the calculation instead of 1024
-k is equal to — block-size=1K
-l, — count-links if hard connected, Calculate its size
-m is equal to — block-size=1M
-l, — dereference finds the true destination indicated by any symbolic link
-p, — no-dereference does not follow any symbolic link (default)
-0, — null regards each blank line as 0 bytes instead of a newline
-s, — separate dirs does not include subdirectory occupancy
-s,
-x;
-x;
-x;
-x;
-x;
-x;
-x;
-x;
— exclude=PATTERN files that match the PATTERN described in the specified file
— exclude=PATTERN files that match the PATTERN described in the specified file
— max-depth=N display directory total (used with -all calculation files)
calculates depth N when N is the specified value;
— max-depth=0 equals — summarize
— time summarize
— time=WORD display WORD time, not change time: atime, access, use, ctime or status
— time-style= style display time according to the specified style (same as the “date” command) : FORMAT
full-iso, long-iso, iso, +FORMAT
— help display this help information and exit
— version display version information and exit

3. df

df-hl view disk remaining space
df-h view the partition size of each root path
du-sh [directory name] return the size of the directory
du-sm [folder] return the total number of M of the folder

4. The difference between

du is a file-oriented command that only calculates the space occupied by the file, not the space occupied by the file system metadata.
df is calculated based on the overall file system, and the size of the allocated space in the system is determined by the unallocated space in the file system. The DF command can get how much space is taken up by the hard disk and how much space is left, and it can also show how all file systems are using I nodes and disk blocks.

Read More: