This question already has an answer here:

Is there a way to get files/directories permissions in number format "0777" instead of "-rw--r--r" format?

marked as duplicate by Maythux, Amith KK, Avinash Raj, mikewhatever, BuZZ-dEE Mar 7 '14 at 21:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can display the octal permissions for a file using the stat command:

stat -c %a [filename]

Or by using find:

find [path] -printf '%m %p\n'

Note that find is recursive, and will print all files in all subdirectories as well. You can use options like maxdepth or prune to stop it from recursing.


I know this is an old post but I found it while looking for a solution to this, and expanded upon it:

stat -c '%a - %n'

That will show the file permissions and the file name. This allows you to see the permissions of every file in a folder with:

stat -c '%a - %n' *

I also took this a step further and made an alias:

alias perms="stat -c '%a - %n'"

So typing perms * will give me the permissions of every file or perms file.php will give me the permissions of just that one file.


You can also use this workaround:

find FILENAME/DIRECROY -printf "%m:%f\n"

Example check my Videos directory:

find Videos -printf "%m:%f\n"


Another Method:

Used to list all directory files with their permissions

ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \
             *2^(8-i));if(k)printf("%0o ",k);print}'

Not the answer you're looking for? Browse other questions tagged or ask your own question.