You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

OCI: How to Get File Permissions in Octal Mode Using stat Command

edited Sep 12, 2024 2:26PM in Linux

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

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!