Get numeric (octal) permissions of a file or directory

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

To get the bitmask style

$: stat -c %A filename