EDUCBA

EDUCBA

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

Linux Directory Permissions

By Priya PedamkarPriya Pedamkar

Home » Software Development » Software Development Tutorials » Linux Tutorial » Linux Directory Permissions

Linux Directory Permissions

Introduction to Linux Directory Permissions

In the Linux operating system, the directory permission is used to grant the access to the user to access the specific directory. The permission level of directory is bit similar with file. In the directory permission, we need to take care of read permission, write permission and execute permission. In the Linux ecosystem, we are getting the multi user environment i.e. multiple users can access the Linux environment as well as access the directory structure. To avoid any data loss or any untrusted user access. It is mandatory to keep the proper permission directory on the respective directory.

Note: When the directory owner will create any directory then
he or she will get the full access on the new created directory and group, other users will get the read and execute access only.

Syntax of Directory Permission

Given below is the syntax of Directory Permission:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

ll [ Directory Name ] chmod [ OPTION ] [ Access Type ] [ Directory Name/Path ] chown [ OPTION ] [ Owner/Group ] [ Directory Name/Path ]

  • ll: The “ll” command is useful to print the directory permission information of the specific directory.
  • chmod: We can use the chmod keyword in the syntax or command. It will take the two arguments as access permission and the directory name or path. As per the provided arguments, it will change the directory permission of the specified directory.
  • chown: The “chown” keyword is similar to “chmod”. But here, we are using chown for changing the directory owner and group.
  • OPTION: We can provide the different flags as options that are compatible with the “chmod” and “chown” command.
  • Access Type: We can provide the different flags of access permission that are compatible with the “chmod” command.
  • Directory Name/Path: As per the requirement, we can provide the name or path of the directory to change the permission.

How Linux Directory Permission works?

The directory permission works on the basis of below two points:

  • Permission/Access Type
  • Access group or user

As per the above two points, we can set or define the directory permissions on the directory.

1. Permission/Access Type: In the Linux environment, the permission type will be read, write and execute.

2. Access group or user: We can define or grant access to a specific group or the users. Accordingly, the directory permission the specific group or user can access the directory.

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)

Below are the lists of directory permission options available:

Sr. No Option Description
1 -4, –read We can use the integer value as “4” to grant the read access on the directory.
2 -2, –write We can use the integer value as “2” to grant the write access on the directory.
3 -1, –execute We can use the integer value as “1” to grant the execute access on the directory.

Examples of Linux Directory Permissions

Given below are the examples mentioned :

Example #1

Directory Permission

It is a very simple and common way to check the directory permission in a Linux environment. It will print the current information of directory permission on the Linux terminal.

Code:

ls -l /

Explanation:

  • As per the below screenshot, we are able to get the different directory access type information. The entire directory having “root” owner and “root” group access.

Output:

Linux Directory Permissions 1

Example #2

Directory Permission – Change to “read” Permission

By default, when any directory will create then the directory owner having the full permission. The group and others will have the read and execute permission. But we can change the directory permission to read-only.

Code:

chmod 444 data

Explanation:

  • We are changing the access type of the “data” directory from 755 (-rwx rx rx) to 444 (- r r r). On “data” directory, the owner, group and other only are having the read access.

Output:

Linux Directory Permissions 2

Linux Directory Permissions 3

Example #2

Directory Permission – Change to “write” Permission

In the directory permission concept, we are able to change the permission from the current state to write permission. We need to use the “2” (write) integer value with the chmod command.

Code:

chmod 222 data

Explanation:

  • We are changing the access type of the “data” directory from 444 (-r r r) to 222 (- w w w). On “data” directory, the owner, group and other only is having them write access.

Output:

Change to “write”

Linux Directory Permissions 5

Example #3

Directory Permission – Change to “execute” Permission

In the Linux environment, we are able to change the permission from the current state to execute permission. We need to use the “1” (execute) integer value with the chmod command.

Code:

chmod 111 data

Explanation:

  • We are changing the access type of the “data” directory from 222 (-w w w) to 111 (- e e e). On “data” directory, the owner, group and other only are having the execute access.

Output:

Change to “execute”

Linux Directory Permissions 7

Example #4

Directory Permission – Change the Directory “Owner”

In the Linux ecosystem, we are having the functionality to change the directory owner from the current owner to requested user.

Note: While doing this change, it is mandatory that the login user is the owner of the directory or have sufficient privileges on the same working directory.

Code:

chown test_user:root data

Explanation:

  • As per the above command, we are able to change the “data” directory owner from “root” user to “test_user” user.

Output:

“Owner”

Linux Directory Permissions 9

Example #5

Directory Permission – Change the Directory “Group”

As per the directory owner change, we can also change the access directory group as well.

Code:

chown test_user: test_user data

Explanation:

  •  As per the above command, we are able to change the “data” directory group from the “root” group to “test_user” group.

Output:

Linux Directory Permissions 10

Linux Directory Permissions 11

Example #6

Directory Permission – With Option “-R”

In the Linux environment, we are having a huge amount of files as well as the sub-directories. It is not possible to change the directory permission one by one. To overcome this problem, we are having the “-R” option. With the help of this option, we can set the directory permission recursively.

Code:

chmod -R 777 data/
chown -R test_user: test_user data/

Explanation:

  • As per the above two commands, we are able to reclusively change the “data” directory access type from 755 (-rw r r) to 777 (-rwerwerwe) and the owner and group from “root” to “test_user”.

Output:

With Option “-R”

Conclusion

We have seen the uncut concept of “Linux Directory Permission” with the proper example, explanation and command with different outputs. The directory permission is very important in terms of security point of view. We are able to change the access type of the directory as well as the directory owner and group.

Recommended Articles

This is a guide to Linux Directory Permissions. Here we discuss the introduction to Linux Directory Permissions, how directory permission works with examples. You may also have a look at the following articles to learn more –

  1. Linux Users
  2. Linux comm
  3. Linux Regular Expression
  4. Linux Alias Command

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