Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Ask, Amith KK, Avinash Raj, mikewhatever, BuZZ-dEE Mar 7 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.

3 Answers 3

up vote 15 down vote accepted

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.

share|improve this answer
    
Awesome, thanks! –  amosrivera Mar 8 '11 at 17:31

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.

share|improve this answer

You can also use this workaround:

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

Example check my Videos directory:

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

755:Videos

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}'
share|improve this answer

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