File System and Permissions (ACL)
This page brings together the Linux directory structure and how to grant access to those files (basic permissions and ACL).
File System and Directory Structure
Linux treats everything as a file. The top-level directory is / (root), and everything branches out below it.
/
├── home/ # home directories of regular users
├── var/ # variable data such as logs and caches
│ └── log/ # where system/app logs are stored
├── etc/ # configuration files
└── usr/ # programs and librariesPaths handled directly in this mission
| Path | Purpose |
|---|---|
/home/agent-admin/agent-app | AGENT_HOME (app root) |
/var/log/agent-app | Stores monitoring logs |
/etc/ssh/sshd_config | SSH configuration file |
File Permissions and ACL
Basic Permission Structure
-rwxr-x--- 1 agent-dev agent-core monitor.sh
^^^ owner group
|||
||+-- others : --- (no permissions)
|+--- group : r-x (read/execute)
+---- owner : rwx (read/write/execute)Numeric Permission Notation
| Number | Meaning |
|---|---|
| 4 | Read (r) |
| 2 | Write (w) |
| 1 | Execute (x) |
bash
chmod 750 monitor.sh
# 7 = rwx (owner)
# 5 = r-x (group)
# 0 = --- (others)Key Commands
bash
# Change owner/group
chown agent-dev:agent-core monitor.sh
# Change permissions
chmod 750 monitor.sh
# Check permissions
ls -l monitor.shACL (Access Control List)
Basic permissions can only be set at three levels: owner, group, and others. ACL is used to grant additional, individual permissions to specific users or groups.
bash
# Install ACL
apt install acl
# Grant rwx permissions to a specific group
setfacl -m g:agent-core:rwx /var/log/agent-app
# Check ACL
getfacl /var/log/agent-appSummary
| Item | Details |
|---|---|
| Directory structure | home, var/log, etc, usr under / |
| Basic permissions | 3 levels: owner / group / others, r=4 w=2 x=1 (e.g. chmod 750) |
| Change owner | chown agent-dev:agent-core monitor.sh |
| ACL | Adds individual permissions for specific users/groups (setfacl -m, getfacl) |
Source: Codyssey-B1/B4-1
