linux:shell_commands:chmod_nummeric

Differences

This shows you the differences between two versions of the page.


linux:shell_commands:chmod_nummeric [2019/10/31 09:05] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== Display numeric permissions using ls ======
 +Create an alias for the LS command.
 +<code bash>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}'</code>
  
 +Output should be with the nummeric permissions at the beginning of each row:
 +<code bash>
 +adm@lxpssl:/home$ 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}'
 +total 3
 +755 drwxr-xr-x 2 adm        domain users 1024 Mar 22  2016 adm
 +755 drwxr-xr-x 2 adm1       domain users 1024 Feb 11  2016 adm1
 +755 drwxr-xr-x 2 adm2       domain users 1024 Apr 11  2016 adm2
 +adm@lxpssl:/home$
 +</code>