0
0
Cybersecurityknowledge~10 mins

File permissions and access control in Cybersecurity - Interactive Code Practice

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

Complete the code to represent the read permission in Unix file permissions.

Cybersecurity
read_permission = '[1]'
Drag options to blanks, or click blank then click option'
Ar
Bw
Cx
Dd
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing write permission 'w' with read permission.
Using 'x' which stands for execute permission.
2fill in blank
medium

Complete the code to check if a user has execute permission on a file.

Cybersecurity
if permissions & [1]:
    print("User can execute the file")
Drag options to blanks, or click blank then click option'
A0o400
B0o100
C0o200
D0o1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong octal value for execute permission.
Confusing execute permission with directory bit 0o1000.
3fill in blank
hard

Fix the error in the code to correctly set write permission for the group.

Cybersecurity
new_permissions = current_permissions | [1]
Drag options to blanks, or click blank then click option'
A0o2000
B0o200
C0o002
D0o020
Attempts:
3 left
💡 Hint
Common Mistakes
Using owner write permission 0o200 instead of group write.
Using directory sticky bit 0o2000 by mistake.
4fill in blank
hard

Fill both blanks to create a dictionary mapping users to their access level, filtering only those with read permission.

Cybersecurity
access_levels = {user: level for user, level in user_permissions.items() if level & [1] == [2]
Drag options to blanks, or click blank then click option'
A0o400
B0o200
C0o100
D0o000
Attempts:
3 left
💡 Hint
Common Mistakes
Using write or execute bits instead of read.
Comparing to zero which would select users without read permission.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps filenames to their permissions, including only files with execute permission set.

Cybersecurity
exec_files = {filename: perms for filename, perms in files.items() if perms & [1] == [2] and perms & [3] != 0}
Drag options to blanks, or click blank then click option'
A0o100
C0o001
D0o400
Attempts:
3 left
💡 Hint
Common Mistakes
Using read or write bits instead of execute bits.
Mixing up user and others permission bits.