Advertisement
Interview Question
Which command would you use to find the largest files/directories consuming disk space in a path?
Key Points to Cover
- `du -sh * | sort -h` to summarize and sort by size
- `du -ah /path | sort -h | tail` for top offenders
- Optionally use `ncdu` for interactive exploration
Evaluation Rubric
Provides correct du usage50% weight
Sorts human-readable sizes25% weight
Mentions ncdu or alternatives25% weight
Hints
- 💡Remember `-x` to stay on one filesystem if needed.
Common Pitfalls to Avoid
- ⚠️Failing to sort the output (e.g., just `du -sh`), which makes identifying the largest items difficult without manual scanning.
- ⚠️Omitting the `-h` (human-readable) flag, resulting in raw byte counts that are cumbersome and time-consuming to interpret quickly.
- ⚠️Not understanding the distinction between `du` (disk usage of specific files/directories) and `df` (filesystem free space for entire partitions).
- ⚠️Forgetting to use `sudo` or appropriate permissions when necessary, which can lead to incomplete or inaccurate results due to inaccessible directories.
- ⚠️Only looking at directory sizes (default `du`) and missing individual large files by not using the `-a` option when a comprehensive file-level scan is needed.
Potential Follow-up Questions
- ❓How to exclude directories?
- ❓How to check inode usage?
Advertisement
Related Questions
Questions that share similar topics with this one
Find Top CPU Processes in Linux
Beginner📞 Phone Screen•1 min•Phone
Troubleshooting High Memory in Linux
Intermediate📞 Phone Screen•2 min•Phone
Bash Shebang & Execute Bit
Beginner📞 Phone Screen•1 min•Phone
CPU Load Average Explained
Intermediate📞 Phone Screen•2 min•Phone
Node Disk Full
Intermediate🔧 Troubleshooting Scenarios•10 min•Scenario