DF looks at the size of the first-level directory, but cannot view the size of the file. Du can view the directory or file size.
1 Basic usage of DF
The DF command displays the total space of all current file systems and the currently available space, using the following:
-A All File system list
-h easy to read mode display
-H equals "-H", but the formula, 1k=1000, rather than 1k=1024
-I display inode information
-K block is 1024 bytes
-L show local file system only
-M block is 1048576 bytes
--no-sync Ignore sync command
-P output format POSIX
--sync perform the sync command before obtaining the disk information
-T File system type
[[email protected] ~]# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda2 20399996 16324496 3039212 85%/
Tmpfs 953276 240448 712828 26%/DEV/SHM
/DEV/SDA1 198337 30091 158006 16%/boot
/dev/sda5 18640184 7205252 10488040 41%/Home
Most commonly used with parameter usage: df-h
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda2 20G 16G 2.9G 85%/
Tmpfs 931M 235M 697M 26%/DEV/SHM
/DEV/SDA1 194M 30M 155M 16%/boot
/dev/sda5 18G 6.9G 11G 41%/Home
The parameter-H indicates the use of the "human-readable" output, that is, in the file system size using GB, MB and other easy-to-read format.
Basic usage of 2 du
Query query file or folder takes up disk size,
-H: Displays a human-readable display of-a: Displays the size of the disk space occupied by the directory and the size of the disk space under which the directory and file is used-s: Displays the amount of disk space occupied by the directory and does not show the size of disk space used by its subdirectories and files-sh: Human readable way to display the size of disk space Do not display the amount of disk space that is used by the subdirectory and the file-C: Displays the amount of disk space occupied by several directories or files, and also counts their sum--apparent-size: Displays the size of the directory or file itself-L: Statistics hard links take up disk space size- L: The size of the file that the statistical symbolic link points to takes up--max-depth=1: Displays the size of this directory and subdirectories
Du: A command that takes no parameters du, loops through the space used by all files and folders, and if a directory contains too many files, it is unfriendly to use.
[email protected] ~]# du
4./.ssh
4./.gnote/addins
16./.gnote
4./videos
16./.gnupg
8./.abrt
4./downloads
4./templates
4./.gvfs
24./.local/share/applications
28./.local/share
32./.local
8./.gconf/apps/panel/applets/workspace_switcher/prefs
12./.gconf/apps/panel/applets/workspace_switcher
8./.gconf/apps/panel/applets/clock/prefs
12./.gconf/apps/panel/applets/clock
8./.gconf/apps/panel/applets/window_list/prefs
12./.gconf/apps/panel/applets/window_list
40./.gconf/apps/panel/applets
44./.gconf/apps/panel
8./.gconf/apps/gnome-terminal/profiles/default
12./.gconf/apps/gnome-terminal/profiles
16./.gconf/apps/gnome-terminal
8./.gconf/apps/brasero/config/priority
16./.gconf/apps/brasero/config
..........
..........
Common parameter modes:
Du-h--MAX-DEPTH=1/USR shows the size of/usr and all secondary directories
[Email protected] ~]# du-h--MAX-DEPTH=1/USR
44m/usr/libexec
4.0k/usr/games
46m/usr/sbin
16m/usr/include
243m/usr/local
12g/usr/oracle
608m/usr/lib
12k/usr/src
4.0k/usr/etc
970m/usr/lib64
1.3g/usr/share
167m/usr/bin
15g/usr
Du-s: When you use this option, Du displays only the size of the disk space that the directory occupies, not the information that its subdirectories and files consume disk space.
[Email protected] ~]# du-s/usr
15303668/usr
Du-sh: View the total capacity of the current directory, not the capacity occupied by each subkey separately.
[Email protected] ~]# du-sh/home/oracle/oradata;
2.7g/home/oracle/oradata
Du--apparent-size: Displays the size of the file or directory itself, not the amount of disk space they occupy. The size of a file or directory that occupies disk space is sometimes not exactly the same size as it is.
[email protected] ~]# du--apparent-size/home/oracle/oradata;
2816061/home/oracle/oradata/backup
2816065/home/oracle/oradata
DU-C: When you use this option, not only does it show a few files or directories that each occupy the size of disk space, they also count the sum.
[Email protected] ~]# du-c/home/oracle/oradata;
2816076/home/oracle/oradata/backup
2816080/home/oracle/oradata
2816080total
Linux df and du usage