By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Access control models define who can do what in your systems. If you mess this up, you get: - Data breaches (e.g., an intern accidentally deleting production databases). - Compliance violations (e.g., failing an audit because contractors have admin access). - Operational chaos (e.g., no one knows who can approve changes, so everything stalls).
Real-world scenario: You’re a sysadmin at a healthcare company. A doctor needs temporary access to patient records for an emergency. Your current system (DAC) lets the doctor’s manager grant access—but what if the manager is on vacation? RBAC (role-based) would let you assign a "Temporary Clinician" role in seconds. ABAC (attribute-based) could auto-grant access if the doctor’s shift is "night emergency" and the patient’s status is "critical."
This guide will show you: ? How to implement each model in real systems (AWS, Linux, Windows). ? How to spot exam traps (e.g., "Which model enforces mandatory access?"). ? How to avoid production disasters (e.g., "Why DAC is a nightmare for compliance").
chmod 755 file.txt
Role
ClusterRole
Condition
aws:SourceIP
aws:CurrentTime
chmod
useradd
aws iam
Goal: Restrict a file so only the owner can read/write it.
bash echo "Top Secret Data" > secret.txt ls -l secret.txt # Check current permissions (-rw-r--r--)
-rw-r--r-- means:
-rw-r--r--
rw-
r--
Restrict access to owner only: bash chmod 600 secret.txt # Owner: RW, Group/Others: None ls -l secret.txt # Now shows -rw-------
bash chmod 600 secret.txt # Owner: RW, Group/Others: None ls -l secret.txt # Now shows -rw-------
Verify: bash sudo -u nobody cat secret.txt # Should fail (Permission denied)
bash sudo -u nobody cat secret.txt # Should fail (Permission denied)
Why this matters: If you leave files as 644 (world-readable), any user (or malware) on the system can read them.
644
Goal: Use SELinux to block a web server from accessing a file.
Check SELinux status: bash sestatus # Should say "enforcing"
bash sestatus # Should say "enforcing"
Create a restricted file: bash echo "SELinux Test" > /var/www/html/restricted.txt chmod 644 /var/www/html/restricted.txt
bash echo "SELinux Test" > /var/www/html/restricted.txt chmod 644 /var/www/html/restricted.txt
Try to access it via Apache (should fail): bash curl http://localhost/restricted.txt # 403 Forbidden
bash curl http://localhost/restricted.txt # 403 Forbidden
Check SELinux denial logs: bash grep "denied" /var/log/audit/audit.log
bash grep "denied" /var/log/audit/audit.log
You’ll see avc: denied { read } because Apache (httpd_t) isn’t allowed to read files labeled default_t.
avc: denied { read }
httpd_t
default_t
Fix it (temporarily): bash chcon -t httpd_sys_content_t /var/www/html/restricted.txt curl http://localhost/restricted.txt # Now works
bash chcon -t httpd_sys_content_t /var/www/html/restricted.txt curl http://localhost/restricted.txt # Now works
Why this matters: Without MAC, a hacked web server could read any file on the system (e.g., /etc/shadow).
/etc/shadow
Goal: Create an IAM role for a "DevOps Engineer" with specific permissions.
Create a policy (JSON): json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:Describe*", "s3:ListAllMyBuckets" ], "Resource": "*" } ] } Save as devops-policy.json.
json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:Describe*", "s3:ListAllMyBuckets" ], "Resource": "*" } ] }
devops-policy.json
Create the policy in AWS: bash aws iam create-policy --policy-name DevOpsReadOnly --policy-document file://devops-policy.json
bash aws iam create-policy --policy-name DevOpsReadOnly --policy-document file://devops-policy.json
Create a role and attach the policy: bash aws iam create-role --role-name DevOpsEngineer --assume-role-policy-document '{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "sts:AssumeRole" }] }' aws iam attach-role-policy --role-name DevOpsEngineer --policy-arn arn:aws:iam::123456789012:policy/DevOpsReadOnly
bash aws iam create-role --role-name DevOpsEngineer --assume-role-policy-document '{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "sts:AssumeRole" }] }' aws iam attach-role-policy --role-name DevOpsEngineer --policy-arn arn:aws:iam::123456789012:policy/DevOpsReadOnly
Test the role (switch to it): bash aws sts assume-role --role-arn arn:aws:iam::123456789012:role/DevOpsEngineer --role-session-name TestSession
bash aws sts assume-role --role-arn arn:aws:iam::123456789012:role/DevOpsEngineer --role-session-name TestSession
bash aws ec2 describe-instances # Should work aws s3 cp s3://secret-bucket/file.txt . # Should fail (no permission)
Why this matters: If you give users individual permissions, you’ll drown in access requests. RBAC scales.
Goal: Allow S3 access only from a specific IP range.
Create a policy with a condition: json { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": "s3:*", "Resource": "*", "Condition": { "IpAddress": { "aws:SourceIp": "203.0.113.0/24" } } }] } Save as ip-restricted-s3.json.
json { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": "s3:*", "Resource": "*", "Condition": { "IpAddress": { "aws:SourceIp": "203.0.113.0/24" } } }] }
ip-restricted-s3.json
Attach it to a user: bash aws iam create-policy --policy-name IPRestrictedS3 --policy-document file://ip-restricted-s3.json aws iam attach-user-policy --user-name Alice --policy-arn arn:aws:iam::123456789012:policy/IPRestrictedS3
bash aws iam create-policy --policy-name IPRestrictedS3 --policy-document file://ip-restricted-s3.json aws iam attach-user-policy --user-name Alice --policy-arn arn:aws:iam::123456789012:policy/IPRestrictedS3
Test it:
203.0.113.5
bash aws s3 ls # Works
198.51.100.5
bash aws s3 ls # Fails (Access Denied)
Why this matters: ABAC lets you enforce dynamic rules (e.g., "Only allow access during business hours").
chmod 777
640
rw-r-----
750
rwxr-x---
audit2allow
aws:MultiFactorAuthPresent
Role-<Department>-<Purpose>
Role-Finance-ReadOnly
Policy-<Service>-<AccessLevel>
Policy-S3-ReadWrite
Environment=Prod
Owner=Alice
auditd
chown
/var/log/audit/audit.log
AssumeRole
s3:PutBucketPolicy
iam:CreatePolicyVersion
Deny
Allow
aws iam simulate-principal-policy
grep "avc: denied" /var/log/audit/audit.log
RBAC (roles are assigned, not enforced by the system).
"You need to grant access based on job title. Which model?"
ABAC (too complex for simple role-based access).
"A user can share files with anyone. Which model is this?"
MAC (system enforces access).
"You need to restrict access to a file based on time of day. Which model?"
You’re a Linux admin. A developer (dev1) needs to run a script (/opt/app/deploy.sh) but gets Permission denied. The script is owned by root:root with 700 permissions. Fix it without making the script world-readable.
dev1
/opt/app/deploy.sh
Permission denied
root:root
700
sudo chown root:dev /opt/app/deploy.sh # Change group to "dev" sudo chmod 750 /opt/app/deploy.sh # Owner: RWX, Group: RX, Others: None sudo usermod -aG dev dev1 # Add dev1 to the "dev" group
Why it works: - 750 = Owner (root) has full access, group (dev) can read/execute. - dev1 is now in the dev group, so they inherit group permissions.
root
dev
chmod 640 file.txt
777
chcon -t httpd_sys_content_t file.txt
aws iam attach-role-policy --role-name Dev --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
"Condition": { "IpAddress": { "aws:SourceIp": "203.0.113.0/24" } }
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.