Back to commands

Linux Survival Basics

Read-only

Trace Every Parent Directory on a Permission Denial

You need to inspect each directory component in a path to find where traversal permission fails.

Command

namei -l /srv/www/example/current/config/prod.token

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not stop at the final file mode; parent execute bits and symlink targets matter.

Expected output

A component-by-component ownership and mode trace for the full path.

System impact

Read-only. Nothing changes. The command shows each path component with owner and mode.

Recovery / rollback: no state is changed.

When to use it

Use when a process gets permission denied even though the final file looks readable.

When not to use it

Do not stop at the final file mode; parent execute bits and symlink targets matter.

next steps

Related commands

Hosting Operations Can be slow

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
Linux Survival Basics Read-only

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
Linux Survival Basics Read-only

Check Web File Owner and Mode

The file can exist and still be unreadable to Nginx.

stat -c '%A %U:%G %n' /srv/www/site/index.html
Hosting Operations Can be slow

Find Release Files Writable Outside the Owner

A release file that someone besides the owner can modify deserves a second look.

find /srv/www/example/releases/current -type f -perm /0022 -printf '%M %u:%g %p\n' 2>/dev/null | sort
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.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.