0
0
Linux CLIscripting~5 mins

du (disk usage by directory) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the du command do in Linux?
The du command shows the disk space used by files and directories. It helps you see how much space each folder or file takes.
Click to reveal answer
beginner
How do you display the disk usage of a directory in a human-readable format?
Use du -h directory_name. The -h option shows sizes in KB, MB, or GB, making it easier to understand.
Click to reveal answer
intermediate
What does the du -s option do?
The -s option summarizes the total disk usage of the directory without listing each subdirectory separately.
Click to reveal answer
intermediate
How can you find the top 5 largest directories using du?
Run du -h --max-depth=1 | sort -hr | head -5. This lists directories with sizes, sorts them from largest to smallest, and shows the top 5.
Click to reveal answer
beginner
Why might you use du instead of df?
du shows disk usage by directories and files, helping find space hogs. df shows free space on disks overall. Use du to find what uses space inside a disk.
Click to reveal answer
Which du option shows sizes in KB, MB, or GB?
A-a
B-s
C-h
D-c
What does du -s /home/user do?
AShows free disk space on /home/user
BLists all files in /home/user
CShows disk usage of each file in /home/user
DShows total disk usage of /home/user only
How do you limit du to show only the first level of subdirectories?
A--max-depth=1
B-h
C-a
D-s
Which command helps find the largest directories quickly?
Adu -s
Bdu -h --max-depth=1 | sort -hr | head -5
Cdf -h
Dls -lh
What is the main difference between du and df?
A<code>du</code> shows usage by directory; <code>df</code> shows disk free space
B<code>du</code> shows free space; <code>df</code> shows usage by directory
CBoth show the same information
DNeither shows disk usage
Explain how to use du to find which directories use the most disk space in your home folder.
Think about showing sizes, limiting depth, sorting, and picking top results.
You got /5 concepts.
    Describe the difference between du and df and when you would use each.
    One looks inside folders, the other looks at the whole disk.
    You got /4 concepts.