Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

namei

Follow a path step by step and show every directory and link on the way, with owner and permissions.

Level
Everyday Linux
Group
Permissions
Needs root
No
Package
util-linux

What it does

"Permission denied" often comes from a directory higher up in the path, not from the file. namei -l PATH lists each part of the path with its mode, owner and group, so you see at once where an x is missing. It also follows symbolic links and shows where they point.

How to write it

namei [OPTION]... PATHNAME...

Options 9

Most used

-l, --long
Show mode, owner and group (same as -m -o -v).
-m, --modes
Show the mode (permissions) of each part.
-o, --owners
Show owner and group of each part.
-v, --vertical
Line up the modes in a column.
-x, --mountpoints
Show mount point directories with a D.
-Z, --context
Show the SELinux context of each part.
-h, --help
Show help.
-V, --version
Show the version.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Check the whole path

    namei -l /srv/sales/plan.txt
    f: /srv/sales/plan.txt
    dr-xr-xr-x root root  /
    drwxr-xr-x root root  srv
    drwxrws--T root sales sales
    -rw-r--r-- anna sales plan.txt

    Others have no x on sales: they cannot reach plan.txt.

  2. 2Find where a link points

    namei /etc/localtime
    f: /etc/localtime
     d /
     d etc
     l localtime -> ../usr/share/zoneinfo/Europe/Amsterdam

    Follows every link to the real file.

  3. 3Debug a web server 403

    namei -l /var/www/html/app/index.html

    The apache user needs x on every directory and r on the file.

  4. 4Show SELinux labels on the way

    namei -Z /var/www/html/index.html

    Next step after the modes: the SELinux types.

  5. 5Show mount points in the path

    namei -x /home/lisa/data

    D marks a directory where another file system is mounted.

  6. 6Only modes, lined up

    namei -mv /etc/ssh/sshd_config

    Short view.

  7. 7Do not follow links

    namei -n /usr/bin/python3

    Shows the link itself only.

  8. 8Check an NFS home path

    namei -l /home/lisa/projects

    A root_squash export or a wrong mode on the mount point shows up here.

  9. 9Check a path for another user

    su - carol -c 'namei -l /data/sales/bob.txt'

    Run it as the user who has the problem.

  10. 10Find a broken link

    namei /opt/app/current

    "No such file or directory" shows which link target is missing.

Exit codes

0 :: Done. 1 :: Error (for example a part of the path does not exist).

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man namei