Obtaining File Permissions in Octal Notation

ls -l can report file permission in symbolic notation:

-rw-r--r--  1 josh  staff    24B Mar 22 21:28 myfile.txt

However, obtaining the permissions in octal notation instead (in this case 644) isn't as easy. The following command will do so.

On macOS:

stat -f '%Lp' filename

On Linux:

stat -c '%a' filename
Home | Back to blog

This work is licensed under CC BY-NC 4.0 Creative Commons BY-NC image