Dangerous Commands
Read-onlyInspect Permissions Before Changing Them
A file or directory has a permission issue, but recursive fixes could break more than they repair.
Command
namei -l /var/www/example/index.html
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not use inspection as the final fix; it only identifies where the permission problem is.
Expected output
A component-by-component permission and owner listing for the path.
System impact
Read-only. Nothing changes. The command shows permissions for each path component.
May require elevated permissions on protected paths or service-owned files.
Recovery / rollback: no state is changed.
When to use it
Use this before `chmod -R` or `chown -R` so you know which layer actually blocks access.
When not to use it
Do not use inspection as the final fix; it only identifies where the permission problem is.
next steps
Related commands
Check Owner and Mode in One Line
The file existed. The owner and mode explained why it still failed.
stat -c '%A %U:%G %n' /var/www/example/index.html
Trace Every Parent Directory on a Permission Denial
The file mode can look fine while a parent directory blocks the whole path.
namei -l /srv/www/example/current/config/prod.token
Audit a Symlink Permission Chain
A symlink can make the path you audited different from the file the app opens.
find /srv/www/example -type l -printf '%p -> %l\n' -exec namei -l {} \; 2>/dev/null
Find Writable Directories Missing the Sticky Bit
A writable log directory is not the same thing as a safe shared directory.
find /srv/www/example -type d -perm -0002 ! -perm -1000 -printf '%m %u:%g %p\n' 2>/dev/null | sort
Find Loose Private Key Permissions
SSH private keys should not be readable like ordinary files.
find /home -type f -name 'id_*' -printf '%m %p\n' 2>/dev/null | awk '$1 > 600'
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.