Numerical permissions with ls on Linux

Sometimes you need to get numerical permissions while doing ls. Numerical permissions are like 777 or 644.

Here is how to do it:

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

You can create a bash file in /usr/local/bin to access this command quickly

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.