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
- Top Kubernetes Courses Online – IT & Software Development [Udemy]
- 10 Free Kubernetes Courses Online Tutorials [Udemy]
- Linux Operating Systems for Kubernetes – OS Support
- Container 101 Tutorials: Kubernetes Technology
- 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.
Take a look at the sample output of ls -l command: available at https://linux.die.net/man/1/ls.
Now, lets go ahead to break it up for better to understanding:
Note that it is important to note that while these three permissions are added to files or folders, because they vary.
Register Courses for this Year
- Coursera Cyber Security Courses Online Free and Paid Classes
- 15 Best Cyber Security Courses | Coursera Online Free Training
- 10 Free Kubernetes Courses Online Tutorials [Udemy]
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
- 2021 Best Salary Paying IT Certifications in-Demand
- Microsoft Certifications with Highest Salary in Demand 2021
- Most in-Demand IT Certifications for Beginners & Pros
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
- 16 Best Ethical Hacking Courses on Udemy in 2021
- [Udemy] 15 Best SQL Courses and Certifications 2021
- Top Best Android Development Courses on Udemy [2021]
- IIBA Certifications – International Institute of Business Analysis
- IIBA Specialized Business Analysis Certifications Guide
- Top IIBA Core Business Analysis Certifications Guide