check a file's permissions

See who may read, write and run a file or a folder, and why a path is refused.

  • files
  • security

Steps

  1. ls -l file.txt

    rwx for the owner, the group and everyone else, then owner and group

  2. ls -ld folder

    a folder's own permissions, not its contents

  3. stat -c '%a %U:%G %n' file.txt

    the permissions as a number, owner and group (GNU)

  4. namei -l /path/to/file.txt

    every folder on the way: one without x refuses the whole path

  5. id

    your user and groups, to compare

Notes

  • macOS: stat -f '%Lp %Su:%Sg %N' file.txt.

Commands used

  • ls
  • stat
  • namei
  • id

Each has a page in lore: lore ls opens it.