Search code examples
unixrhel7

Get CHMOD Value and Owner name - Unix


Their is any command to get CHMOD value and Owner name of a directory on Unix

expected output: PATH/OF/DIR 777 ADMIN


Solution

  • stat -c "%n %a %U" -- *
    

    Change the wildcard to a specific directory as you wish/need.

    From man stat:

    -c  --format=FORMAT
              use the specified FORMAT instead of the default; output a newline after each use of FORMAT
    
    %a     access rights in octal (note '#' and '0' printf flags)
    %n     file name
    %U     user name of owner