I heard from a guy who recently started with Linux that when he wants to see file permissions in Linux in the octal format…because he is not to clear with permissions in human-friendly format…he open FileZilla, then do right click on file – Properties….and that is a way how he see permissions in octal format. Why octal? Because he is not familiar with chmod in human-friendly format.
Here’s an example of copying permissions between files, where you have only fuman-friendly format and don’t know for octal.
For privilege listing in octal format, we will use command ‘stat’ which is part of coreutils package. Syntax in bellow
stat -c 'SOME FORMAT' filename
For format, if you want only to list permissions in octal format, next parameters can be interesting for you:
- %a – Show me a permissions in octal format
- %A – Show me a permissions in human-friendly format (like in ls -l)
- %n – Show me file name
…so for listing in this case – we can use next command: stat -c ‘%a %A %n’ testfajl*
Other interesting parameters for stat:
- %F – Show me a file type (regular file, empty file, directory, symlink…)
- %U – Show me a username of file owner
- %G – Show me a owner group
- %x – Show me last access date
- %w – Show me when was file created
- %y – Show me when was last modification time
- Other characters for easier print and formatting, without % (like –>, ->, |, name, whatever)
Here is a more ‘advanced’ listing
So now, you can list file permissions in octal format and to use your usual chmod XXX command.