The standard ls command shows permissions on folders and files as text strings, for example, "drwxr-xr-x" or similar. However, sometimes you need to see these same permissions in numeric form, for example, to specify them via the chmod command for another filesystem item.
The following will help us with that:
$ stat -c '%a %n' *
Running this command, you'll see a list of files and directories with numeric permission identifiers on the left. Here's an example:
$ cd /var
$ stat -c '%a %n' *
755 backups
755 cache
755 chroot
755 lib
2775 local
1777 lock
755 log
2775 mail
755 opt
755 run
755 spool
1777 tmp
755 www
PS. Recursively (for example, for automatic execution in scripts) you can view this as follows:
$ find /mypath -printf "%m:%p\n"
In the output, separated by a ":" character, you'll get a list of files and folders along with their permissions, starting from the mypath directory.
Comments