Welcome to the Linux Foundation Forum!

Linux Command Line: Difficulty Understanding File Permissions

Options

I'm relatively new to Linux, and I'm having some trouble understanding file permissions and how they work. I've read about the chmod command and the three types of permissions (r, w, x), but I'm still unsure about some aspects.

Here's what I've learned so far:

r (read): Allows viewing the content of a file.
w (write): Permits modifying the content of a file.
x (execute): Grants the ability to run an executable file or navigate into a directory.
However, I'm struggling to grasp how these permissions apply to different user types (owner, group, and others). Also, I'm not entirely sure about the numeric representation of permissions (e.g., 755, 644).

Could someone provide a clear breakdown of how file permissions work in Linux? How do they differ for different user types? And what's the significance of the numeric representation? If you could include some real-world examples or scenarios, it would greatly help in understanding this fundamental aspect of Linux. Thank you in advance for your assistance!

Comments

  • lfid01
    lfid01 Posts: 1
    edited September 2023
    Options

    Hi Vikash11,

    The permission positions are :

    owner group world (omitted the first directory/setuid/guid position )

    rwx rwx rwx
    421 421 421
    --- --- ---

    where

    r=4
    w=2
    x=1

    therefore,
    chmod 755 foo makes the permissions:

    -rwxr-xr-x

    owner rwx (4 + 2 + 1 = 7)
    group r-x (4 +1 = 5)
    others r-x (4 +1 = 5)

    chmod 644 foo makes:

    -rw-r--r--

    owner rw- (4 + 2 = 6)
    group r-- (4 = 4)
    others r-- (4 = 4)

    If a file has rw- as the group permissions it is readable and writable by users who belong to the same group.

    You can read more about permissions in section 104.5 Manage file permissions and ownership of the LPIC-1 course learning materials:
    https://learning.lpi.org/en/learning-materials/101-500/
    https://learning.lpi.org/pdfstore/LPI-Learning-Material-101-500-en.pdf

    Hope this helps!

    Kind regards,
    Matthew

Categories

Upcoming Training