df Command in Linux
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreOverview
The df command in Linux is used to display the disk space usage of file systems. It provides a snapshot of the total space, used space, available space, and the percentage of space used on each mounted file system.
Linux df Command Syntax
The syntax for the df command is as follows:
Where:
- OPTIONS: The options or flags used to modify the behavior of the df command.
- FILE: The file or file system for which the disk usage information is required. If not provided, df will display information for all mounted file systems.
df Command Options:
- -a, --all: Include dummy file systems and display information for all file systems.
- -h, --human-readable: Display sizes in a human-readable format (e.g., 1K, 234M, 2G).
- -T, --print-type: Display the file system type.
- -i, --inodes: Display inode information instead of block usage.
Example Usages
-
Display disk usage for all mounted file systems.:
Output:
Explanation: This command displays the disk usage of all mounted file systems with their respective sizes in 1K blocks.
-
Display disk usage for all file systems in human-readable format.:
Output:
Explanation: This command displays the disk usage of all mounted file systems with their respective sizes in a human-readable format.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
Use the -h or --human-readable option to make the output easier to understand.
-
Combine the -T and -h options to display both the file system type and sizes in a human-readable format.
Advanced Use Cases of df Command in Linux
-
Display disk usage for a specific file or directory.:
Output:
Explanation: This command displays the disk usage of the file system containing the specified file or directory.
-
Display inode information for all file systems.:
Output:
Explanation: This command displays the inode information of all mounted file systems.
-
Display disk usage with file system type for all mounted file systems.:
Output:
Explanation: This command displays the disk usage of all mounted file systems along with their file system type and sizes in a human-readable format.
Turn Learning into Career Growth
Conclusion
-
The df command is used to display the disk space usage of file systems.
-
It provides information about total space, used space, available space, and the percentage of space used.
-
Use the -h option to display sizes in a human-readable format.
-
The -T option displays the file system type.
-
The -i option displays inode information instead of block usage.