Friday, April 26, 2024
702
rated 0 times [  702] [ 0]  / answers: 1 / hits: 501232  / 2 Years ago, mon, december 27, 2021, 8:49:25

There is a chmod command to set file permissions, but can I get file permissions in octal mode (such as 755) from the command line?


More From » command-line

 Answers
7

You can try



stat -c "%a %n" *


Replace * with the relevant directory or the exact filename that you want to examine.



From the man page of 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
%n File name


Usage:




  • With files:



    $ stat -c "%a %n" ./Documents/Udev.html 
    664 ./Documents/Udev.html

  • With folders:



    $ stat -c "%a %n" ./Documents/
    755 ./Documents/



(Reference)


[#37525] Wednesday, December 29, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atchcommo

Total Points: 114
Total Questions: 130
Total Answers: 101

Location: Cook Islands
Member since Sat, Oct 16, 2021
3 Years ago
atchcommo questions
Fri, May 13, 22, 08:22, 2 Years ago
Wed, Mar 9, 22, 20:14, 2 Years ago
;