Complete the code to represent the read permission in Unix file permissions.
read_permission = '[1]'
The letter r stands for read permission in Unix file systems, allowing a user to view the contents of a file.
Complete the code to check if a user has execute permission on a file.
if permissions & [1]: print("User can execute the file")
The execute permission for the user (owner) is represented by the octal value 0o100. Using bitwise AND checks if this permission is set.
Fix the error in the code to correctly set write permission for the group.
new_permissions = current_permissions | [1]The group write permission is represented by 0o020. Using bitwise OR adds this permission without affecting others.
Fill both blanks to create a dictionary mapping users to their access level, filtering only those with read permission.
access_levels = {user: level for user, level in user_permissions.items() if level & [1] == [2]This code filters users who have the read permission bit set (0o400). The condition checks if the read bit is exactly present.
Fill all three blanks to create a dictionary comprehension that maps filenames to their permissions, including only files with execute permission set.
exec_files = {filename: perms for filename, perms in files.items() if perms & [1] == [2] and perms & [3] != 0}The code filters files that have the user execute bit (0o100) exactly set and also have the others execute bit (0o001) set. This ensures files are executable by user and others.