Linux File Permissions: A Beginner's Guide

Linux File Permissions: A Beginner's Guide

Hello there! Today, we're delving into the fascinating world of Linux file permissions. Let me ask you a question first, are you afraid of that 'drwxrwxr-x' before we start? If so, do not be afraid! After reading this blog, you'll have a solid understanding. Anyway, let's get started!

Similar to UNIX, Linux is an operating system that allows several users to access it at once. However, with this accessibility comes a security concern – a sneaky or malicious user could tamper with critical data. Linux uses two levels of authorization, to address this:

  • Ownership
  • Permission

Understanding Linux file ownership is paramount. There are three different kinds of owners for every file or directory in Linux: User, Group, and Other.

  1. User: A file's default owner is the person who created it; this person is frequently referred to as the owner.

  2. Group: A user group is made up of several users who share the same file rights under Linux. Members of the project can collaborate more easily as a result.

  3. Other: Any user who has access to a file but is not a group member or the owner.

Now Linux File Permissions:

Read (r), Write (w), and Execute (x) are the three permissions that each file and directory in Linux has for the three owners mentioned . Each file and directory in Linux has three permissions for the three owners mentioned above.

  • Read(r): Enables file opening and reading. It allows folders to list their contents.

  • Write (w): Permits changing the contents of a file or adding, deleting, and renaming files inside of a directory.

  • Execute (x): Required in order to run a program. If not set, you are unable to run the program code but are still able to examine and alter it. Determining user behavior in Linux requires an understanding of these permissions.

Let's look at some file permissions:

'-rwxrw-r--' in the command Linux permissions for the owner, user group, and others. Every character denotes: r = read permission w = write permission x = execute permission = no permission

for example, 'rw-' indicates that the owner can read and write to the file but not execute it.

In Linux, modifying file permissions Using the command "chmod": Setting permissions (read, write, execute) for the owner, group, and other users is made possible via the 'chmod' command, which stands for 'change mode'.

Syntax:

COPY

chmod permissions filename

The command can be used in Absolute mode or Symbolic mode.

  1. Absolute (Numeric) Mode: Represents permissions as a three-digit octal number.

    The table below gives numbers for all for permissions types.

  2. Symbolic Mode: Modifies permissions for specific owners using mathematical symbols.

Changing Group and Ownership in Linux: Use the 'chown' command to change the group or ownership of a file or directory. Use 'chown user:group filename' to modify both. To modify the group alone, use 'chgrp group_name filename'.

Changing Ownership and Group in Linux

Use the 'chown' command to change the group or ownership of a file or directory.

COPY

chown user filename

Use 'chown user:group filename' to modify both.

COPY

chown user:group filename

To modify the group-owner only, use 'chgrp group_name filename'.

COPY

chgrp group_name filename

chgrp’ stands for change group.

That's all I have to say. I hope you have a pleasant day!!!!

Let's connect and grow on Linkedin :Click Here

Let's connect and grow on Twitter :Click Here

Happy Reading!!!!!

Sudha Yadav