Back to lessons

Dangerous Commands

Inspect 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

What changed

Nothing changes. The command shows permissions for each path component.

Danger

safe

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.

Undo or recovery

No state is changed.

Expected output

A component-by-component permission and owner listing for the path.

demo script

Disposable terminal steps

  1. ls -l /var/www/example/index.html
  2. namei -l /var/www/example/index.html
  3. stat /var/www/example/index.html

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ ls -l /var/www/example/index.html
-rw-r----- 1 root root 14 Jun 25 13:19 /var/www/example/index.html
::exit-code::0
$ namei -l /var/www/example/index.html
f: /var/www/example/index.html
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-x--- root root www
drwxr-x--- root root example
-rw-r----- root root index.html
::exit-code::0
$ stat /var/www/example/index.html
  File: /var/www/example/index.html
  Size: 14        	Blocks: 8          IO Block: 4096   regular file
Device: 0,158	Inode: 4           Links: 1
Access: (0640/-rw-r-----)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-06-25 13:19:21.772065763 +0000
Modify: 2026-06-25 13:19:21.772065763 +0000
Change: 2026-06-25 13:19:21.774065792 +0000
 Birth: 2026-06-25 13:19:21.772065763 +0000
::exit-code::0

YouTube Short

Inspect before you chmod.

Recursive chmod is tempting because it is fast. Inspect the path first so you fix the layer that is actually blocking access.

LinkedIn hook

The permission fix was easy. Knowing what not to chmod was the hard part.

Question: What permission command do you trust before reaching for `chmod -R`?

experiments

A/B tests to run

Metric: linkedin_comment_rate

A: Inspect permissions before changing them.

B: This is what I run before `chmod -R`.