Bird
Raised Fist0
Cybersecurityknowledge~30 mins

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

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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
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
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
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
Hint

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

Practice

(1/5)
1. What does the read permission allow a user to do with a file?
easy
A. Modify the contents of the file
B. View the contents of the file
C. Execute the file as a program
D. Delete the file

Solution

  1. Step 1: Understand the meaning of read permission

    The read permission allows a user to open and see the contents of a file without changing it.
  2. Step 2: Compare with other permissions

    Write permission allows changes, execute allows running the file, and delete is a separate action.
  3. Final Answer:

    View the contents of the file -> Option B
  4. Quick Check:

    Read permission = View file contents [OK]
Hint: Read means viewing file contents only [OK]
Common Mistakes:
  • Confusing read with write permission
  • Thinking read allows file execution
  • Assuming read allows file deletion
2. Which of the following is the correct symbolic notation for giving the owner execute permission on a file in Unix/Linux?
easy
A. u+x
B. g+x
C. o+x
D. a+x

Solution

  1. Step 1: Understand symbolic notation for permissions

    In Unix/Linux, 'u' stands for user (owner), 'g' for group, 'o' for others, and 'a' for all.
  2. Step 2: Identify execute permission addition

    Adding execute permission is done with '+x'. So 'u+x' means add execute for owner.
  3. Final Answer:

    u+x -> Option A
  4. Quick Check:

    Owner execute permission = u+x [OK]
Hint: u means owner; +x adds execute permission [OK]
Common Mistakes:
  • Using g+x or o+x for owner permissions
  • Confusing a+x with owner only
  • Misunderstanding symbolic letters
3. Given the file permission string -rwxr-x---, which users can execute the file?
medium
A. Owner and group members
B. Only the owner
C. Everyone
D. Only others

Solution

  1. Step 1: Break down the permission string

    The string '-rwxr-x---' means: owner has read, write, execute; group has read and execute; others have no permissions.
  2. Step 2: Identify who can execute

    Owner (rwx) can execute, group (r-x) can execute, others (---) cannot.
  3. Final Answer:

    Owner and group members -> Option A
  4. Quick Check:

    Execute permission for owner and group [OK]
Hint: Look for 'x' in owner and group parts [OK]
Common Mistakes:
  • Ignoring group execute permission
  • Assuming others have execute
  • Misreading permission string
4. A user tries to write to a file but gets a 'Permission denied' error. The file permissions are -rw-r--r--. What is the most likely cause?
medium
A. User has execute permission but not write
B. File is read-only for everyone
C. User is not the owner and has no write permission
D. File is locked by another process

Solution

  1. Step 1: Analyze the permission string

    '-rw-r--r--' means owner can read and write; group and others can only read.
  2. Step 2: Understand user's permission

    If the user is not the owner, they only have read permission, so writing is denied.
  3. Final Answer:

    User is not the owner and has no write permission -> Option C
  4. Quick Check:

    Write denied if not owner with write permission [OK]
Hint: Write permission only for owner here [OK]
Common Mistakes:
  • Assuming read means write allowed
  • Confusing execute with write permission
  • Ignoring ownership in permissions
5. You want to allow a group of users to read and execute a script but prevent them from modifying it. Which permission setting should you apply?
hard
A. Set group permissions to ---
B. Set group permissions to rw-
C. Set group permissions to rwx
D. Set group permissions to r-x

Solution

  1. Step 1: Understand required permissions

    Users need to read and execute but not write (modify) the script.
  2. Step 2: Match permissions to requirements

    'r-x' means read and execute allowed, write denied. 'rw-' allows write, 'rwx' allows all, '---' denies all.
  3. Final Answer:

    Set group permissions to r-x -> Option D
  4. Quick Check:

    Read + execute, no write = r-x [OK]
Hint: r-x means read and execute, no write [OK]
Common Mistakes:
  • Choosing rw- which allows writing
  • Choosing rwx which allows all permissions
  • Choosing --- which denies access