Friday, April 10, 2009

Display file permission in octal - Linux stat

File permissions in Linux can be displayed in octal format using Linux stat command.

from man page of Linux stat(1) command

%A Access rights in human readable form
%a Access rights in octal
%n File name

$ stat -c '%A %a %n' *

One sample output:

-rwxr-xr-x 755
drwxr-xr-x 755 old_dump
-rw-r--r-- 644


Unknown said...

Here's what I used to help my coworker fix his mistake.

On a known good server:
find /Pristine/Dir stat -c'chown %a %n' {} \; > /tmp/

On server with messed up perms:
chmod 700 /tmp/

GenSirHughGough said...

I think edcrosbys meant

find /Pristine/Dir -exec stat -c'chown %a %n' {} \; > /tmp/

Unknown said...

@GT, thanks.

© Jadu Saikia