Back to commands

Dangerous Commands

Read-only

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

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.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ ls -l /var/www/example/index.html

-rw-r----- 1 root root 14 Jun 26 00:27 /var/www/example/index.html

$ 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

$ stat /var/www/example/index.html

  File: /var/www/example/index.html
  Size: 14        	Blocks: 8          IO Block: 4096   regular file
Device: 0,162	Inode: 4           Links: 1
Access: (0640/-rw-r-----)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-06-26 00:27:11.890296539 +0000
Modify: 2026-06-26 00:27:11.890296539 +0000
Change: 2026-06-26 00:27:11.892296562 +0000
 Birth: 2026-06-26 00:27:11.890296539 +0000
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

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

next steps

Related commands

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
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 fixtures/perm-audit -type l -printf '%p -> %l\n' -exec namei -l {} \;
Cybersecurity Triage Can be slow

Find Writable Directories Missing the Sticky Bit

A writable log directory is not the same thing as a safe shared directory.

find fixtures/perm-audit -type d -perm -0002 ! -perm -1000 -printf '%m %u:%g %p\n' | sort
Cybersecurity Triage Can be slow

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' | 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.

  • lpic1:103-gnu-unix-commands
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • linuxplus:troubleshooting
  • risk:read-only

Useful for

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

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