Eureka Moment Wiki

One eureka moment at the time

User Tools

Site Tools


linux:shell_commands:chmod_nummeric

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:shell_commands:chmod_nummeric [2016/12/19 15:25]
tplecko
linux:shell_commands:chmod_nummeric [2017/08/10 13:00] (current)
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>​
linux/shell_commands/chmod_nummeric.txt · Last modified: 2017/08/10 13:00 (external edit)