QA
Beginner LevelLinux Commands & SysAdmin

How do df and du check disk space usage and directory sizes?

❓ Interview Prompt: Explain df -h (filesystem disk usage) vs du -sh (directory disk usage) and identifying large files.

Checking disk storage utilizes two complementary CLI tools:

1. 'df -h' (Disk Free):

Reports total, used, and available disk space across all mounted filesystems in human-readable format (GB/MB).

2. 'du -sh *' (Disk Usage):

Calculates accumulated disk space consumed by specific files or directories.

•
'-s': Summary for directory.
•
'-h': Human-readable units.

Code Implementation Example

bash
# Check free space across all mounted filesystems
df -h

# Find top 10 largest subdirectories in /var
du -sh /var/* | sort -rh | head -n 10
💡Inspecting filesystem space with df -h and top directory usage with du -sh.
🎯 Interview Key Takeaway

Use df -h to check overall filesystem capacity, and du -sh to locate large folders consuming disk space.

#df#du#Disk Usage#Storage#Beginner
Back to all Linux Commands & SysAdmin Questions→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?