Get numeric (octal) permissions of a file or directory

Revision history
Tags: linux

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

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.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.