df command
linux의 df
명령어를 통해 현재 디스크의 전체 사용량을 확인 할 수 있습니다.
기본 사용법
$> df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 8123612 0 8123612 0% /dev
tmpfs 1630992 17960 1613032 2% /run
/dev/mapper/mint--vg-root 229063924 159664024 57741048 74% /
tmpfs 8154948 554936 7600012 7% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 8154948 0 8154948 0% /sys/fs/cgroup
/dev/sda1 482922 279826 178162 62% /boot
cgmfs 100 0 100 0% /run/cgmanager/fs
tmpfs 1630992 520 1630472 1% /run/user/1000
출력된 정보는 다음과 같습니다.
Filesystem
: 파일 시스템 이름1K-blocks
: 전체 크기Used
: 사용중인 크기Available
: 사용가능한 크기Use%
: 사용중인 크기 백분율Mounted on
: 마운트된 파일 시스템
활용
$> df -x tmpfs | sed '/^\/dev\/loop/d'
Filesystem 1K-blocks Used Available Use% Mounted on
udev 8123612 0 8123612 0% /dev
/dev/mapper/mint--vg-root 229063924 159665860 57739212 74% /
/dev/sda1 482922 279826 178162 62% /boot
Help
$> df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.
Mandatory arguments to long options are mandatory for short options too.
-a, --all include pseudo, duplicate, inaccessible file systems
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
-H, --si print sizes in powers of 1000 (e.g., 1.1G)
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
--output[=FIELD_LIST] use the output format defined by FIELD_LIST,
or print all fields if FIELD_LIST is omitted.
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
--total elide all entries insignificant to available space,
and produce a grand total
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
FIELD_LIST is a comma-separated list of columns to be included. Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/df>
or available locally via: info '(coreutils) df invocation'
TLDR
$> tldr df
df
Gives an overview of the file system disk space usage.
- Display all file systems and their disk usage:
df
- Display all file systems and their disk usage in human readable form:
df -h
- Display the file system and its disk usage containing the given file or directory:
df path/to/file_or_directory
- Display statistics on the number of free inodes:
df -i
- Display file systems but exclude the specified type:
df -x squashfs -x tmpfs
참고
- df wiki{:target=“blank”}