Linux checks file permissions

Is there a Linux command or a series of commands that will allow me to get the file permissions in octal format (e.g. 0644)?

+3
source share
5 answers

Try stat (1)

stat -c 0%a /etc/passwd
+8
source

From unix.com: screen resolution in octal format :

perl -e 'printf "%o\n", (stat shift)[2] & 07777' filename
+3
source

fstat , st_mode .

0

"stat" ( ), fstat (. "man 2 stat" )

0

OSX:

$ stat -f %p myfile
100644

:

$ stat -f %Lp myfile
644
0
source

Source: https://habr.com/ru/post/1780955/


All Articles