Customizing the Output
For scripting or specific reporting needs, you might want to display only certain columns. The df
command provides the --output
option to customize the fields shown in the report.
You can specify a list of fields you want to see. Common fields include source
(the filesystem), fstype
(filesystem type), size
, used
, avail
, pcent
(use percentage), and target
(mount point).
Let's create a custom report that shows the filesystem source, size, used space, available space, and mount point, all in a human-readable format.
df -h --output=source,size,used,avail,target
This command produces a clean, customized table with only the columns you requested:
Filesystem Size Used Avail Mounted on
overlay 20G 126M 20G /
tmpfs 64M 0 64M /dev
tmpfs 7.7G 0 7.7G /sys/fs/cgroup
shm 64M 0 64M /dev/shm
/dev/nvme1n1 100G 20G 81G /etc/hosts
tmpfs 7.7G 0 7.7G /proc/acpi
tmpfs 7.7G 0 7.7G /proc/scsi
tmpfs 7.7G 0 7.7G /sys/firmware
This feature is powerful for generating concise reports or for feeding data into other scripts, as it allows you to control the output format precisely.