Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to show the permissions of a file named example.txt.
Linux CLI
ls -l [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -a or -h instead of the filename.
Omitting the filename argument.
✗ Incorrect
The command
ls -l example.txt lists detailed information including permissions for the file named example.txt.2fill in blank
mediumComplete the code to add execute permission for the user on script.sh.
Linux CLI
chmod u[1] script.sh Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
-x which removes execute permission.Using
+r which adds read permission instead.✗ Incorrect
The command
chmod u+x script.sh adds execute permission for the user (owner) on the file script.sh.3fill in blank
hardFix the error in the command to remove write permission for the group on data.txt.
Linux CLI
chmod g[1] data.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
+w which adds write permission instead of removing it.Using
-x which removes execute permission instead.✗ Incorrect
To remove write permission for the group, use
chmod g-w data.txt.4fill in blank
hardFill both blanks to create a dictionary comprehension that maps filenames to their permission strings if the permission starts with 'r'.
Linux CLI
permissions = {file: perm for file, perm in files.items() if perm[1]('r') and perm[0][2]'r'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
endswith instead of startswith.Using
!= instead of ==.✗ Incorrect
The code filters files whose permission string starts with 'r' and equals 'r' at position 0 using
startswith and ==.5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps filenames to their permission length if the permission contains 'x' and length is greater than 5.
Linux CLI
result = { [1]: len([2]) for [1], [2] in perms.items() if 'x' in [2] and len([2]) [3] 5 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for both key and value.
Using
== instead of > for length comparison.✗ Incorrect
The comprehension uses
filename and perm as variable names and checks if length of permission is greater than 5 with >.