September 21, 2025
Linux Command Line

Linux Command Line

The ‘df’ command on Linux is a powerful tool that allows you to check the available disk space on your system. This command can be used to check the space on different file systems, including those mounted on external devices such as USB drives. In this article, we will explain when to use the ‘df’ command, how to use it, and provide some examples to help you understand its functionality.

When to use the ‘df’ command:

  • When you need to check the amount of free space on your file system
  • When you need to check the amount of space used by a specific file or directory
  • When you need to check the amount of space used by a specific file system or partition
  • When you want to check the amount of space available on an external device such as a USB drive

How to use the ‘df’ command: The basic syntax of the ‘df’ command is as follows: df [options] [file or directory]

For example, to check the amount of space used by the root file system, you can use the following command: df /

This will return information about the file system that contains the root directory, including the total amount of space, the amount of used space, and the amount of free space.

To check the amount of space used by a specific file or directory, you can specify its path after the ‘df’ command: df /path/to/file

To check the amount of space used by a specific file system or partition, you can specify the file system or partition after the ‘df’ command: df /dev/sda1

To check the amount of space available on an external device such as a USB drive, you can use the following command: df /dev/sdb1

Options for ‘df’ command:

  • -h : Show the amount of space in human-readable format (e.g., 1G instead of 1073741824 bytes)
  • -T : Show the file system type
  • -i : Show the number of inodes on the file system

Examples:

  • To check the amount of space used by the root file system in human-readable format, use the following command: df -h /
  • To check the file system type and the amount of space used by a specific file or directory, use the following command: df -T /path/to/file
  • To check the number of inodes and the amount of space used by a specific file system or partition, use the following command: df -i /dev/sda1

In conclusion, the ‘df’ command on Linux is a powerful tool that allows you to check the available disk space on your system. By understanding when and how to use this command, you can easily check the space usage of your file systems, partitions and external devices. This command can be used in many cases to troubleshoot disk space related issues.

See our list of 75 Linux commands you should know about.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Share via
Copy link
Powered by Social Snap