Managing Disk Space in Linux with the df Command

Managing Disk Space in Linux with the df Command

ยท

2 min read


Introduction

The df command is a useful tool for managing disk space on your Linux system. It displays information about the file system disk space usage, including the amount of free space, used space, and the percentage of space used. Here are some examples of using df command:

Show disk space usage in human-readable format

df -h

Image 1

Show disk space usage for a specific file system

df -hT /dev/sda1

Image 2

Show disk space usage for all file systems (including speudo file systems)

df -aTh

Image 3

Show disk space usage for a specific file system and exclude file systems of a certain type

df -hT -x tmpfs /dev/sda1

Image 4

Show disk space usage in bytes for all file systems (including empty file systems)

df -BT

Image 5

Show disk space usage for a specific file system with inode information

df -i /dev/sda1

Image 6

Show disk space usage with a specific output format

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

Image 7

Show disk space usage sorted by a specific column (ascending)

df -hT | sort -k 3

Image 8

Show disk space usage sorted by a specific column (descending)

df -hT | sort -k 3 -r

Image 9

Show disk space usage for all file systems and exclude the header line

df -hT | tail -n +2

Image 10

Tips

  • Use the h option to display disk space usage in human-readable format (e.g., GB, MB)

  • Use the x option to exclude file systems of a certain type (e.g., tmpfs,devtmpfs)

  • Use the -output option to customize the output format of the command

  • Use the sort and tail commands to sort and filter the output as needed.

Conclusion

In summary, the df command is a powerful tool for managing disk space on your Linux system. With the various options available, you can easily view and analyze disk space usage for specific file systems and customize the output format. Remember to use the available sorting and filtering commands to further manage and analyze the output.

Thank you for reading ๐Ÿง‘โ€๐Ÿ’ป

Stay tuned for more ๐Ÿš€

โœŒ๏ธ and logout

Buy Me A Coffee

ย