6

I know that with "ls -l" I can see the permissions of a file or directory but it shows them with letters, so how to show the permissions in numeric way

for example:

755 /var/www/mywebpage

2 Answers2

15

You could use find :

find . -maxdepth 1 -printf "%m %f\n"

or stat:

stat -c "%a %n" -- *
sebasth
  • 14,872
1

Like stated in this answer on stackoverflow,

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}'

is doing exactly what you want.

ADDB
  • 486