How to get chmod (octal) permissions of the folder in the terminal?
By Emma Johnson •
I can look in properties of this folder but I want to get properties fast and in digits (octal, e.g. 755, etc.)
What am I to type in terminal to know the chmod of the file or folder I want?
3 Answers
What am i to type in terminal to know the chmod of the folder i want?
stat -c %a FILE_OR_FOLDER_PATH
e.g. stat -c %a /etc shows 755
stat FILE_OR_FOLDER_PATHthis is quicker but displays the whole lot
GNU find
Makes use of %m format for -printf flag.
$ find /etc/ -maxdepth 0 -printf "%m\n"
755or
$ find /etc/ -prune -printf "%m\n"
755Python
$ python -c 'import os,sys;print(oct(os.stat(sys.argv[1]).st_mode))' /etc
040755Or if we want to only get the owner-group-other permission bits only:
$ python -c 'import os,sys;print(oct(os.stat(sys.argv[1]).st_mode)[-3:])' /etc
755Perl
Via File::stat, pretty much same as in the documentation:
$ perl -le 'use File::stat; $fs=stat($ARGV[0]);printf "%o\t%s\n",$fs->mode & 07777,$ARGV[0]' /etc
755 /etc More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"