• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Urban Penguin

The Urban Penguin - Linux Training

  • Home
  • About
  • Live Online Courses
  • Shop
  • Programming
    • Master Editing Text Files Using VIM
    • Learn Shell Scripting with BASH
    • PERL Scripting in Linux
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • Learn C Programming using Linux and the Raspberry Pi
    • General Java Tutorials
    • Java 7 OCA Exam 1ZO-803
  • OS Tutorials
    • Red Hat and CentOS Training
      • Red Hat Enterprise Linux System Administration 1 – RH124
      • RHCSA – System Admin 2 – RH134
      • RHCE – EX294 – Automation With Ansible
    • Learning Ubuntu
    • LPI Training
      • LPI Linux Essentials
      • LPIC-1 Linux Administrator
      • LPIC-2 Certified Linux Engineer
      • LPIC-3 Senior Level Certification
        • LPIC-3 Exam 300 : Mixed Environments
        • LPIC-3 Exam 303 : Security
        • LPIC-3 Exam 304 : Virtualization and High Availability
    • Linux Technologies
      • Apache HTTPD Server
      • Learning PHP
      • Learning PUPPET
      • Learning SAMBA
      • Linux File-Systems
      • Monitoring with Nagios Core
      • MYSQL
      • openLDAP Directories on Linux
You are here: Home / Linux / LPIC-3 Exam 303 / Read Linux File Permissions

Read Linux File Permissions

June 19, 2018 by The Urban Penguin

read linux file permissionsAs we dig deeper into the objectives for the LPIC-3 303 exam we now start to look at the discretionary access control lists. This makes up the mode and ACL of a file. The original permissions are known as the file’s mode which were eventually enhanced with ACLs, Access Control Lists. The mode of a file allows for a single user and group to be listed along with others; whereas an ACL allows for multiple users and groups to be listed.

We start by looking at the standard permissions or mode of a file and how we can read Linux file permissions. By this stage you probably can use the command ls -l to read file permissions but you will also learn to use stat to list the octal, symbolic and raw modes of a file.

$ ls -l file1
-rw-rw-r--. 1 centos centos 0 Jun 19 15:56 file1

The long listing  of a file will show the symbolic permissions granted to the user, group and others. The user’s permissions listed first then the group before listing permissions granted to others.

Read Linux File Permissions with stat

We can also read Linux file permissions with the command stat:

$ stat file1

The output is quite verbose and not listed here but we can narrow down to what we want.:

$ stat -c %A file1
-rw-rw-r--
$ stat -c %a file1
664

Here we can see the mode in both the symbolic notation and octal notation. We may think that the octal notation is the way the mode is stored in the meta-data but this would be incorrect. There is a raw mode and stores both the mode and the file type. To view this we use:

$ stat -c %f file1
81b4

The output is in HEX. To view this in a more familiay way lets pass it through the command printf:

$ printf "%o\n" 0x81b4
100664

The first 10 represents the file type, a regular file ion this case. A directory would show as 4 in place of the 10. The file’s mode is 0664 being rw rw and r. To be honest the ls -l command works well but it is good to know the stat command when you need to dig a little deeper.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to print (Opens in new window)

Filed Under: LPIC-3 Exam 303

Primary Sidebar

Newest Video

The Urban Penguin On Youtube

Categories

Pages

  • About The Urban Penguin
  • Contact Us
  • Shop
    • Basket
    • Checkout
    • My Account
  • LPI Training from The Urban Penguin
    • Live and Pluralsight hosted courses
    • Complete Linux Essentials
    • LPIC-3 Senior Level Certification
      • LPIC-3 Exam 300 : Mixed Environments
      • LPIC-3 Exam 303 : Security
      • LPIC-3 Exam 304 : Virtualization and High Availability
    • LPIC-2 Certified Linux Engineer
    • LPIC-1 Linux Administrator
    • LPI Linux Essentials for Raspberry Pi
    • LPI Linux Essentials
  • Operating System Tutorials
    • Linux Foundation Training
    • Solaris 11 OCA 1ZO-821
    • Learning Ubuntu
    • Learning SUSE
    • Red Hat and CentOS Training
      • RHCE – EX294 – Automation With Ansible
      • RHCSA – System Admin 1 – RH124
      • RHCSA – System Admin 2 – RH134
  • Scripting – the power of repetition!
    • Java 7 OCA Exam 1ZO-803
    • General Java Tutorials
    • Learn C Programming using Linux and the Raspberry Pi
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • PERL Scripting in Linux
    • Learn Shell Scripting with BASH
    • Master Editing Text Files Using VIM
  • Linux Technologies
    • Learning PUPPET
    • openLDAP Directories on Linux
    • Monitoring with Nagios Core
    • Linux File-Systems
    • Learning SAMBA
    • Apache HTTPD Server
    • Learning PHP
    • MYSQL
  • OpenStack
    • Pluralsight
    • Udemy
    • Raspberry Pi Tutorials
    • Citrix Videos
  • Online Instructor-led Courses
    • Red Hat Enterprise Linux System Administration 1 – RH124
    • SELinux Masterclass
    • Bash Scripting Masterclass
    • Nftables Masterclass

© 2021 The Urban Penguin · All Rights Reserved