0
0
Linux CLIscripting~10 mins

du (disk usage by directory) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show disk usage of the current directory.

Linux CLI
du [1] .
Drag options to blanks, or click blank then click option'
A-h
B-a
C-s
D-x
Attempts:
3 left
💡 Hint
Common Mistakes
Using -s only shows total size, not all directories.
Using -a shows all files, which is more than needed.
2fill in blank
medium

Complete the code to show only the total disk usage of the current directory.

Linux CLI
du [1] .
Drag options to blanks, or click blank then click option'
A-a
B-h
C-s
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -a lists all files and directories, too much detail.
Using -c adds a grand total, not just the directory total.
3fill in blank
hard

Fix the error in the code to show disk usage in human-readable format for /var directory.

Linux CLI
du -h [1]
Drag options to blanks, or click blank then click option'
A/usr/var
Bvar
C~/var
D/var
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'var' without slash looks in current directory, which may not exist.
Using '~/var' looks in home directory, not /var.
4fill in blank
hard

Fill both blanks to show disk usage of /home directory in human-readable format and summarize only total size.

Linux CLI
du [1] [2] /home
Drag options to blanks, or click blank then click option'
A-h
B-s
C-a
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -a shows all files, not just summary.
Using -c adds a grand total which is not needed here.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each subdirectory in /tmp to its size in human-readable format, only if size is greater than 100K.

Linux CLI
sizes = [1]: subprocess.check_output(['du', '-h', '-s', f'/tmp/[2]']).decode().split()[0] for [3] in os.listdir('/tmp') if int(subprocess.check_output(['du', '-s', f'/tmp/[2]']).decode().split()[0]) > 100}
Drag options to blanks, or click blank then click option'
Ad
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causes errors.
Using 'item' instead of 'd' breaks the comprehension.