How to get octal file permissions on Linux/Unix command line

Originally published at: https://www.cyberciti.biz/faq/get-octal-file-permissions-from-command-line-on-linuxunix/

I am a new Linux command line user. How do I find file permissions in octal format such as 0644 from the bash command line running on a Linux or Unix operating systems? How can I get the octal permissions for a file? How do I get octal file permissions on Linux/Unix?

Hi,
Very simple way is using stat command
see manual page of stat command
there are a lot of other ways and you can download proper scripts from internet

also you can define alias like below
alias ostat='stat -c %a ’
ostat /etc/passwd
output will be similar
644


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki