OCI: How to Get File Permissions in Octal Mode Using stat Command
APPLIES TO:
Linux OS–Version Oracle Linux 7.0 to Oracle Linux 9.0 [Release OL7 to OL9]
Linux x86_64 on Oracle Public Cloud
GOAL:
This document explains the command to get file permissions in Octal mode for an easy file permission change.
SOLUTION:
stat
- display file or file system status
From the 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 %n File name
Usage:
With files and folders:
# stat -c "%a %n" /home/opc /home/opc/.ssh /home/opc/.ssh/authorized_keys 700 /home/opc 700 /home/opc/.ssh 600 /home/opc/.ssh/authorized_keys
Tagged:
0