check a file's permissions
See who may read, write and run a file or a folder, and why a path is refused.
Steps
-
ls -l file.txtrwx for the owner, the group and everyone else, then owner and group
-
ls -ld foldera folder's own permissions, not its contents
-
stat -c '%a %U:%G %n' file.txtthe permissions as a number, owner and group (GNU)
-
namei -l /path/to/file.txtevery folder on the way: one without x refuses the whole path
-
idyour user and groups, to compare
Notes
- macOS:
stat -f '%Lp %Su:%Sg %N' file.txt.
Commands used
lsstatnameiid
Each has a page in lore: lore ls opens it.
Related recipes
- change permissions of a folder and everything in itGive a folder, its subfolders and its files the permissions or the owner they need, without making them open to everyone.
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.
- check a certificateSee a site's TLS certificate, when it expires and who issued it, or the same for a .pem file.