Get numeric (octal) permissions of a file or directory
- 28 Nov 2017: Post was created (diff)
Linux often shows permissions using -rwxrwxrwx
style instead of numerical like 0777
. When I started using Linux, I only knew Linux permissions from using FTP servers, and thought the numbers were called chmod. Now I can share that chmod
is a utility used to modify file and directory permissions.
To get a file’s permissions in octal representation you can use stat -c %a
:
$: stat -c %a filename
666
To get the bitmask style
$: stat -c %A filename
-rw-rw-rw-
References
man stat
man chmod
If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).
Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.