UNIX & Linux File Permissions | Read/Write & Change — Part 1

Managing Basic Permissions. File Permissions in Linux/Unix: How to Read/Write & Change? Understanding Linux File Permissions is the aim of writing this article. After reading this post, you will learn how to also change directory permissions in Linux. In other explanations, this is also known as Unix / Linux – File Permission / Access Modes. While you continue to read from this page, you will get free access to How to Use the chmod Command on Linux too.

Other Courses

  1. Top Kubernetes Courses Online – IT & Software Development [Udemy]
  2. 10 Free Kubernetes Courses Online Tutorials [Udemy]
  3. Linux Operating Systems for Kubernetes – OS Support
  4. Container 101 Tutorials: Kubernetes Technology
  5. 10 Best Udemy Kubernetes Courses & Tutorials [2021]

Linux File Permissions deep dive — Part 1

The permissions for Linux files and directories are separated into three tables, each with three permissions (read, write, and execute) clustered for three different types of files and directories (users, groups and others)

At the beginning, there is also an additional column that will show whether it is either a directory or a connection.

Linux directory or a link - Linux File Permissions
Linux directory or a link

Take a look at the sample output of ls -l command: available at https://linux.die.net/man/1/ls.

Here’s a sample output of ls -l command

Now, lets go ahead to break it up for better to understanding:

Linux read and write command

Note that it is important to note that while these three permissions are added to files or folders, because they vary.

Linux Permission Sample

Register Courses for this Year

How to Use the chmod Command in Linux

You use the chmod command to set permissions for user (u), community (g), and others (read, write, and execute) (o). For reference purposes, a few examples are shown below:

Grants execute permission to user.

Grants read to user and execute to group.

Revokes read and execute from user.

Grants execute for user, group and other.

In addition, Linux permission also have a numerical value associated with each of them which makes it easy to refer and manipulate for each roles.

Few examples:

Grants r,x to user and r to groups and others.

Grants r,w,x to user, w to group and nothing to others

The Venn diagram shown below gives a good perspective of the numerical values for easy referencing.

Certifications

Recursive eXecute permission for only directories and not files:

Listen carefully. If you remember from the beginning of this post, when set to a directory, execute permission allows you to enter/access it, while setting execute permission on a file causes it to run like a programme or script. By design, a directory generated on the Linux filesystem has execute privileges, allowing for directory traversal.

There might be instances, though, where this may be absent and you will need to set execute permissions on all files and sub-folders. Sure, you might use the chmod command’s -R (recursive) option to accomplish this.

Explanation continues. What the above command does is to recursively set the execution permission not only for all sub-folders but also for all directories (a potentially dangerous situation). It’s only important to set it for the directories and not for any of the files.

It means that files do not get execute authorisation with X (uppercase), unless the file has already configured it, which makes it a more intelligent way to deal with execute permissions.

Conclusion:

In conclusion, I hope this article has offered some insight into dealing with Linux’s simple file/directory permissions. In the comments section, please let me know your suggestions (bouquets and brickbats).

Update: Part 2 of this series is available, which addresses advanced Linux permissions (SUID, SGID & Sticky Bit).

Trending IT & Business Courses

  1. 16 Best Ethical Hacking Courses on Udemy in 2021
  2. [Udemy] 15 Best SQL Courses and Certifications 2021
  3. Top Best Android Development Courses on Udemy [2021]
  4. IIBA Certifications – International Institute of Business Analysis
  5. IIBA Specialized Business Analysis Certifications Guide
  6. Top IIBA Core Business Analysis Certifications Guide
Exit mobile version