0
0
Cybersecurityknowledge~30 mins

File permissions and access control in Cybersecurity - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding File Permissions and Access Control
📖 Scenario: You are managing files on a computer system. To keep files safe, you need to set who can read, write, or execute each file. This is called file permissions and access control.Imagine you have a folder with important documents. You want to decide who can open, change, or run these files.
🎯 Goal: Build a simple representation of file permissions using a dictionary. Then, add a rule to check if a user has permission to perform an action on a file.
📋 What You'll Learn
Create a dictionary named files with file names as keys and their permissions as values.
Add a variable named user_action to represent the action a user wants to perform.
Write a loop to check if the user has permission for the action on each file.
Add a final statement that shows which files the user can access based on their action.
💡 Why This Matters
🌍 Real World
File permissions control who can read, write, or execute files on computers, protecting data and system security.
💼 Career
Understanding access control is essential for cybersecurity roles, system administration, and software development to ensure safe data handling.
Progress0 / 4 steps
1
Create the initial file permissions dictionary
Create a dictionary called files with these exact entries: 'report.txt': 'read', 'data.csv': 'write', 'script.sh': 'execute'.
Cybersecurity
Need a hint?

Use curly braces {} to create a dictionary. Each key is a file name string, and each value is a permission string.

2
Add a variable for the user's desired action
Add a variable called user_action and set it to the string 'read'.
Cybersecurity
Need a hint?

Assign the string 'read' to the variable user_action.

3
Check permissions for each file
Use a for loop with variables file and permission to iterate over files.items(). Inside the loop, write an if statement to check if permission == user_action.
Cybersecurity
Need a hint?

Use files.items() to get file and permission pairs. Compare permission with user_action inside the loop.

4
Complete by listing accessible files
Inside the if block, add the file name to a list called accessible_files. Before the loop, create accessible_files as an empty list.
Cybersecurity
Need a hint?

Create an empty list before the loop. Use append() to add files inside the if block.