brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: df --output picks exactly the columns you want, including inode usage

Linux
~/tips/tip-disk-df-output-columns

df -h --output=source,fstype,size,used,avail,pcent,target

Prints only the columns of df that you list, such as mount point, percentage and inode use.

The default df table has columns I rarely need, and cutting them with awk breaks when a mount point has a space in it. GNU df can print only the fields you name.

Give --output a comma-separated list:

df -h --output=source,fstype,size,used,avail,pcent,target

The man page lists the valid names: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file and target. So you can ask for inode numbers next to the space, which gives one view for the two ways a disk gets full:

df -h --output=target,pcent,ipcent /mnt/user

The file argument limits the output to the filesystem that holds that path. Without a field list, --output prints all fields.

A good fit is a script or a cron job that warns you at a threshold. The columns come out in the order you gave and there are no surprises in the layout. Add --total if you want a grand total.

The caveat: --output does not mix with the old options. When I tried df -i --output=target,pcent, df stopped with the message that options -i and –output are mutually exclusive, so the inode fields have to come from the field list. The man page also marks -P (the POSIX format) as a separate output format.

Further reading: df(1) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link