“755”-style permissions with ‘ls’
After a quick Google search for “ls permissions octal” I found a very handy alias to put in my .bashrc. Not only is it handy to see the OCTAL value of the permissions for each file/dir, it will undoubtedly help you more quickly recognize/interpret the normal ls -al output.
1 |
alias lso="ls -alG | 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}'" |
1 2 3 4 |
mycomp:~ adam$ lso 755 drwxr-xr-x 15 adam staff 510 Dec 6 02:47 .vim 644 -rw-r--r-- 1 adam staff 1136 Dec 18 16:55 .vim_mru_files 600 -rw------- 1 adam staff 13665 Dec 18 16:56 .viminfo |
1 |
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}' |