How much
space do I have left on my hard drive? Is there enough free disk space
to download a large file or install a new application?
On Linux based systems you can use the df command to get a detailed report on the system’s disk space usage.
Each
line includes information about the file system name (Filesystem), the
size (1K-blocks), the used space (Used), the available space
(Available), the percentage of used space (Use%), and the directory in
which the filesystem is mounted (Mounted on).
To display
information only for a specific file system pass the filesystem name or
the mount point to the df command. For example to show the space
available on the file system mounted to system root directory / you can use either df /dev/nvme0n1p3 or df /.
df /
Copy
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 222284728 183057872 27865672 87% /
By default, the df
command shows the disk space in 1 kilobyte blocks and the size of used
and available disk space in kilobytes. To view the information
human-readable format (megabytes and gigabytes), pass the -h option:
df -h
Copy
Filesystem 1K-blocks Used Available Use% Mounted on
Filesystem Size Used Avail Use% Mounted on
dev 7.8G 0 7.8G 0% /dev
run 7.9G 1.8M 7.9G 1% /run
/dev/nvme0n1p3 212G 176G 27G 88% /
tmpfs 7.9G 145M 7.7G 2% /dev/shm
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs 7.9G 24K 7.9G 1% /tmp
/dev/nvme0n1p1 511M 106M 406M 21% /boot
/dev/sda1 459G 165G 271G 38% /data
tmpfs 1.6G 16K 1.6G 1% /run/user/1000
If you want to limit listing to file systems of a specific type use the -t option followed by the type. For example to list all ext4 partitions you would run:
df -t ext4
Copy
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 222284728 183666112 27257432 88% /
/dev/sda1 480588496 172832632 283320260 38% /data
Copy
Similar to above, the -x option allows you to limit the output to file systems that are not of a specific type,
When used with the -i
option the df command will display information about the filesystem
inodes usage. For example to show information about the inodes on the
file system mounted to system root directory / in human-readable format you would use:
An
inode is a data structure in a Unix and Linux file systems, which
contains information about a file or directory such as its size, owner,
device node, socket, pipe, etc., except da.
The df command also allows you to specify the output format.
To limit the reported fields shown in the df output use the --output[=FIELD_LIST] option. FIELD_LIST is a comma-separated list of columns to be included in the output. Each field can be used only once. Valid field names are:
source - The File system source.
fstype - The File system type.
itotal - Total number of inodes.
iused - Number of the used inodes.
iavail - Number of the available inodes.
ipcent - Percentage of used inodes.
size - Total disk space.
used - Used disk space.
avail - Available disk space.
pcent - Percentage of used space.
file - The file name if specified on the command line.
target - The mount point.
For
example to display the output of all ext4 partition in human-readable
format, showing only the filesystem name and size and the percentage of
the used space you would use:
By now you should have a good understanding of how to use the df command. You can always view all available df command options by typing man df in your terminal.
No comments:
Post a Comment