EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Linux User Permission

By Alokananda GhoshalAlokananda Ghoshal

Home » Software Development » Software Development Tutorials » Linux Tutorial » Linux User Permission

Linux User Permission

Introduction to Linux User Permission

The following article provides an outline for Linux User Permission. In Linux, like any other operating system, simultaneous multiple users to work on the same server. The working of one user does not disrupt the working of another. In the long run, when multiple users work simultaneously, there is a possibility of sharing files across each other and this leads to a condition where there is risk of exposing some classified piece of information or even lead to data loss due to multiple users having the access to write or modify.

To counter this issue, Linux has a feature of restricting the users on the basis of who should have what power and that entire concept of which user needs to get what power lies with User Permission. And with the upcoming concept of cloud-based system, the user permission in Linux now plays even bigger role for the developers to carefully look at.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax of Linux User Permission

Let us look at syntax of the user permission. Whenever one looks at user permission, only one things resides in the minds of people looking towards it and that is how to change. But, that is just one part of it and the other part is on the how part along with extra utilities which user permission in Linux is capable of.

Given below are the 5 commands:

1. chmod: This command is used for modifying the access rights.

Syntax:

chmod <Permission Number>FileName

2. su: This command enables the actions to be taken as a superuser.

Syntax:

su

3. sudo: This command is also same as su.

Syntax:

sudo

4. chown: This is used for changing the file ownership.

Popular Course in this category
Kali Linux Training (3 Courses, 3+ Projects)3 Online Courses | 3 Hands-on Projects | 21+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,486 ratings)
Course Price

View Course

Related Courses
Linux Training Program (16 Courses, 3+ Projects)Red Hat Linux Training Program (4 Courses, 1+ Projects)

Syntax:

chown <username> FileName

5. chgrp: In order to change file’s group ownership, this command is used.

Syntax:

chgrp <New Group> FileName

Though the next topic in the current section might not be exactly syntactical, but it is an important concept to learn about and this topic is users and groups. These are the entities to which the ownership and permission rules are applied to. Users are nothing but set of ids which can belong to a user of the system or may be a placeholder for some admin work, which are either responsible for running non-interactive process or background process which are referred to as system users and the other is responsible for running interactive process by logging into the system and these users are referred to as regular users. Before we saw about superuser, which is nothing but a “big boss” which can override anyone’s permission.

On the other hand, Groups are nothing but a collection of zero or more users. Also, it is not necessary that a user belonging to a certain group can’t be a part of another group. This is very similar to a distribution list we have at workplace. One can be in a distribution list of HR’s mails and own’s team’s mail as well.

How does Linux User Permission work in Linux?

In order to know the working principle of user permission in Linux, we need to know small components which build the entire channel of user permission.

Where do we find the user permissions?

Syntax:

ls -l

Output:

Linux User Permission 1

Description:

Here the first block refers to the different modes which are present for a particular filename. The filename is mentioned as the last block like dummyfile.sh, newfile.txt. In the next section we will get to know the different components when we input ls -l.

Components of user permission:

Linux User Permission 2

Here the mode is the major component in knowing user permission. Along with that, Owner and group are the second important things which plays an important role in understanding who the group individual will be affected by the permission.

In the next few sections let us see Mode, Owner and Group individually and in detail.

1. Mode: Mode comprises of various sub-components.

Linux User Permission 3

2. File Type: The first section mentions about the File type. In a scenario, there are 2 types of files where one of them is a normal and eventually represented by hyphen (-) and the other is special file type and typically represented by a character. For example, d means that the filename is eventually a directory. There are a lot of other special files but not an essential information keeping this article in mind.

3. Permission Class: The next 9 characters refers to the permission class and each triad refers to each of the 3 groups. User is the one who is the owner of the filename, Group is the cluster to which the user belongs to and others is all the users who don’t fall in the cluster of Group.

Each of the classes have 3 different symbolic permission and they are:

  • R: This refers to provide only read access to the file.
  • W: This refers to provide write access to the file, which includes read access as well.
  • X: This refers to provide execute access to the file, which includes read and write access as well.

In case any of them is not to be provided we use hyphen in place of that. For example, r– means that the file will have only read access to the class.

Now that we have understood the different aspects of user permission, next we would look at how do we change the permission of a particular file. For this we will use the chmod syntax.

Example

For the file dummyfile.sh we would first try to run the file, and in the process we would encounter an error. Next we will change the user permission of user to executable and then try to run again and analyze the output.

Code:

Before executable permission

ls -l
./dummyfile.sh

Changing the permission

chmod 744 dummyfile.sh

Execute script

./dummyfile.sh

Output:

Before executable permission

Before executable

After changing the permission

After changing

Execute script

Execute script

Explanation:

  • The main idea here is to understand how we arrived at number 744. Here’s rule of thumb. If file needs read access, then 4, if it additionally needs write then add 2, and additionally if it needs execute add 1.
  • So, for user class, we have all 3 access, i.e. 4+2+1 = 7. For the other 2 permission class we have only read and hence 4.

Conclusion

With this we have taken a deep dive into user permission in Linux by looking at smaller aspects first in the start and then collectively started adding up and finally able to showcase a shell file getting executed when we changed the permission. One important thing before we wind up is to understand with great power comes great responsibility and hence the permission needs to be well thought of before providing that permission to user or group or others.

Recommended Articles

This is a guide to Linux User Permission. Here we discuss the introduction, how does linux user permission work in linux? and example. You may also have a look at the following articles to learn more –

  1. Linux tracepath
  2. Linux Mount Command
  3. Linux Shred
  4. Linux comm

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Linux Tutorial
  • Linux Commands
    • CAT Command in Linux
    • PS command in Linux
    • Mkdir Command in Linux
    • rmdir command in Linux
    • mv command in Linux
    • Linux rm Command
    • CHMOD Command in Linux
    • Zip Command in Linux
    • Linux Route Command
    • SCP Command in Linux
    • du Command in Linux
    • Less Command in Linux
    • Copy Command in Linux
    • Head Command in Linux
    • Help Command in Linux
    • Linux History Command
    • hostname Command in Linux
    • GREP Command in Linux
    • Linux Curl Command
    • Linux List Users
    • Linux List Directories
    • Linux Directory Permissions
    • Find Directory Linux
    • Linux User Permission
    • Linux Add User
    • Linux Delete User
    • Linux uniq
    • Linux Filter Commands
    • Linux sort Command
    • Linux Sort by Size
    • Remove dir Linux
    • Linux tr Command
    • Linux Touch Command
    • Linux More Command
    • Linux Cal Command
    • Linux OD
    • Linux Zcat
    • Linux tracepath
    • Linux Sleep
    • Linux bg Command
    • Linux WC
    • Linux Read
    • Linux Write
    • Linux Rename Command
    • Linux Free Command
    • Linux tac
    • Linux Shred
    • Linux wget
    • Linux Date
    • Linux Untar
    • Linux JQ
    • Linux Xargs
    • Linux Mount Command
    • Linux mdadm
    • Linux comm
    • Linux tee Command
    • Tail Command in Linux
    • Linux gzip
    • Linux Directory Structure
    • Linux Alias Command
    • Linux Inode
    • Linux Ping
    • Linux Watch Command
    • Linux Split Command
    • Linux Size
    • Linux Network Stack
    • Linux Diff Command
    • Vim Command in Linux
    • Linux nslookup
  • Basic
    • Introduction to Linux
    • What is Linux
    • Careers in Linux
    • How to Install Linux
    • How to Install Ubuntu
    • How to Install Ubuntu Server
    • How To Install Debian
    • Advantage Of Linux
    • What is Raid in Linux
    • What is Raid 5?
    • Raid 5 vs Raid 6
    • Careers in Linux Administration
    • What is Shell in Linux?
    • Bash Shell in Linux
    • Linux Emulator
    • Linux Operators
    • Linux Apps
    • Linux Keyboard Shortcuts
    • Linux Crontab
    • What is Raid Storage
    • What is Vmware
    • What is RedHat
    • What is Debian
    • Uses of Ubuntu
    • Career In RedHat
    • Linux Distributions
    • Linux From Scratch
    • Linux Format
    • Cheat Sheet Linux
  • Advanced
    • Install VMware
    • Install GRUB
    • Chown Command in Linux
    • Linux Network Command
    • Configuring Linux Network Environment
    • DNS Configuration in Linux
    • Linux Users
    • Create User in Linux
    • DHCP Server in Linux
    • FTP Server in Linux
    • Linux Regular Expression
    • IP Command in Linux
    • Set IP Address in Linux
    • Tar Command in Linux
    • Dynamic Host Configuration Protocol
    • Linux Kill Signals
    • Linux File Permissions
    • Linux File System
    • Linux Create File
    • Linux Concatenate Files
    • Linux Join
    • Linux Process Management
    • Linux Proxy Server
    • Linux System Commands
    • Linux System Logging
    • NFS in Linux
    • Linux LVM
    • Linux Repository
    • Samba Server in Linux
    • Top Commands in Linux
    • Types of Shells in Linux
    • Shell Script Types For Linux
    • GCC Command in Linux
    • Monolithic Kernel
    • YARN Package Manager
    • Linux Sed Replace
    • Linux List Groups
    • Linux Container
    • Linux Find File by Name
    • Create Folder in Linux
    • Linux Move Folder
    • Linux Error Codes
    • Linux Automount
    • Linux HugePages
  • Kali Linux
    • Install Kali Linux
    • Kali Linux Uses
    • Kali Linux Commands
    • Kali Linux Repository
    • Kali Linux Packages
    • Kali Linux root password
    • Kali Linux Alternative
  • Interview Questions
    • Linux Interview Questions
    • Linux System Administration Interview
    • Red Hat Interview Questions

Related Courses

Kali Linux Training

Linux Training Course

Red Hat Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Kali Linux Training Learn More