dfx
Report file system space usage.
Mirrors GNU df. Run it as dfx, or as gnux dfx.
Synopsis
dfx [OPTION]... [FILE]...GNU reference
Description
dfx shows, for each mounted file system, its size, the space used and available, the percentage used and where it is mounted. With FILE operands it shows only the file systems holding them. Sizes are in 1024-byte blocks by default; -h prints them like 23G (--si/-H in powers of 1000), -k and -m use KiB and MiB, and -B SIZE any unit. Use% is used/(used+available), rounded up, so space reserved for the superuser shows as used. -i reports inodes instead of blocks, -T adds the file system type, -P uses the POSIX format, and --output=FIELDS chooses the columns (source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target). -t TYPE and -x TYPE select or exclude file system types, -l leaves out network file systems, and --total adds a grand total. Without -a, pseudo file systems (proc, sysfs, devfs, ...), file systems with no blocks and duplicate mounts of the same device are left out; -a shows them all, with '-' for any that cannot be examined. The block size defaults to DF_BLOCK_SIZE, BLOCK_SIZE or BLOCKSIZE when set. GNU df only runs where coreutils is installed; dfx reports the mounted file systems on Linux, macOS and FreeBSD, and on Windows lists every drive (C:, D:, network drives) with the same columns, quietly skipping a card reader or DVD drive with no medium. --sync and --no-``sync are accepted and have no effect, and -v is ignored, as in GNU. On a terminal, dfx shows gnux's view (--pretty=auto, the default; GNUX_PRETTY changes it): the table is framed, with a rule under the header and before --total's row, a usage bar in a column after each percentage (green, then yellow from 75% and red from 90%), and the header and mount points colored in the theme --theme or GNUX_THEME names (NO_COLOR keeps it uncolored). A table wider than the terminal (COLUMNS, else its own width) cuts its widest text column short with an ellipsis, so the frame never wraps. Piped or redirected output, and -P, stay exactly GNU's; --pretty=always asks for the view anyway and --pretty=never turns it off.
Permissions
Needs no special permission; a mount point the user cannot examine is left out (or shown with '-' under -a).
Use cases
- Checking how much free space is left before a large download, build or backup.
- Finding which disk is filling up on a server.
- Checking which file system a directory lives on, and its type.
- Running out of inodes despite free space: checking with
-i. - Seeing at a glance which disk is nearly full, from the colored usage bars.
- Alerting from a script when a disk passes a usage threshold.
Flags
-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
-x, --exclude-type TYPE limit listing to file systems not of type TYPE
--help display this help and exit
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
-i, --inodes list inode information instead of block usage
-k, --kilobytes 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
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
-T, --print-type print file system type
-H, --si print sizes in powers of 1000 (e.g., 1.1G)
--sync invoke sync before getting usage info (no effect)
-v, --sysv (ignored)
--theme NAME color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
--total elide all entries insignificant to available space, and produce a grand total
-t, --type TYPE limit listing to file systems of type TYPE
--version output version information and exitExamples
Your laptop warned that the disk is almost full: see every volume's usage as a bar, the full ones in red
dfx -hSee at a glance how full every disk is
dfx -hFilesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 469G 301G 145G 68% /
/dev/nvme0n1p1 511M 6.1M 505M 2% /boot/efi
/dev/sda1 1.8T 1.6T 163G 91% /mnt/backupBefore a 20 GB download, check the free space where it will land
dfx -h ~/DownloadsFilesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 469G 301G 145G 68% /Show only real local disks, with their file system types
dfx -hlTFilesystem Type Size Used Avail Use% Mounted on
/dev/nvme0n1p2 ext4 469G 301G 145G 68% /A server says 'No space left on device' but df shows free space: check the inodes
dfx -i /varFilesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 1310720 1310720 0 100% /Alert from a cron job when the root disk passes 90%
[ "$(dfx --output=pcent / | tailx -n 1 | trx -dc 0-9)" -gt 90 ] && echox 'root disk above 90%'Print just the available space, in megabytes, for a script
dfx -BM --output=avail /data | tailx -n 1 48213MSee which device and file system type a directory is on
dfx --output=source,fstype,target /var/lib/dockerFilesystem Type Mounted on
/dev/nvme0n1p2 ext4 /Total the space across all local disks
dfx -hl --totalCheck only the network shares
dfx -h -t nfs -t cifsLeave temporary file systems out of the report
dfx -h -x tmpfs -x devtmpfsProduce stable, parseable output with the POSIX format
dfx -P | tailx -n +2Show disk space in the portable gnux shell, the same on every OS
gnux shell -c 'dfx -h . && dux -sh .'Options
Each option has a page of its own, with its usage and examples.
- -a, --all: Include pseudo, duplicate, inaccessible file systems.
- -B, --block-size: Scale sizes by SIZE before printing them; e.g., '
-BM' prints sizes in units of 1,048,576 bytes. - -x, --exclude-type: Limit listing to file systems not of type TYPE.
- -h, --human-readable: Print sizes in powers of 1024 (e.g., 1023M).
- -i, --inodes: List inode information instead of block usage.
- -k, --kilobytes: Like
--block-size=1K. - -l, --local: Limit listing to local file systems.
- --no-sync: Do not invoke
syncbefore getting usage info (default). - --output: Use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.
- -P, --portability: Use the POSIX output format.
- --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default. - -T, --print-type: Print file system type.
- -H, --si: Print sizes in powers of 1000 (e.g., 1.1G).
- --sync: Invoke
syncbefore getting usage info (no effect). - -v, --sysv: (ignored).
- --theme: Color the view with the built-in theme NAME (
gnuxtheme picks and saves one); GNUX_THEME sets the default. - --total: Elide all entries insignificant to available space, and produce a grand total.
- -t, --type: Limit listing to file systems of type TYPE.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
dfx --help # options, first examples, exit status
gnux help dfx # this page: the full manual
gnux help dfx --OPTION # one option in depth, with its examples