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

To get the bitmask style

$: stat -c %A filename


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.