Solved

folder permissions in Linux

Posted on 2014-02-26
11
397 Views
Last Modified: 2014-03-14
I want to create a folder , then  give Read and Execute permissions to a group. what 's the right command?

for instance.

I create a folder named Marketing, then give MarketingGroup Read/Execute permissions, no one else will have permissions on this folder.

Thanks
0
Comment
Question by:jskfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 1

Assisted Solution

by:Archzilon Eshun-Davies
Archzilon Eshun-Davies earned 84 total points
ID: 39889965
FIrst create the directory

mkdir <folder>

Open in new window


using Marketing as example
mkdir Marketing

Open in new window


normally the default permission after creating a directory is 0755 but you can double check
to be safe by applying the permission
chmod 755 <folder>

Open in new window

using Marketing as an example it'll become
chmod 755 Marketing

Open in new window


and then change the owner of the directory as follows
chown :<group> <directory>

Open in new window

and again using the Marketing as an example it would be come
chown :MarketingGroup Marketing

Open in new window

0
 

Author Comment

by:jskfan
ID: 39890814
chown :MarketingGroup Marketing

I thought the command above will give ownership of the Marketing folder to MarketingGroup, which means x7x

in my case I need to give folder creator , ownership, which is Read/write/Execute,  the MarketingGroup will have Read/Execute, and anyone else nothing

if I am understanding Linux permissions at all:

XYZ: means user X si the folder creator, automatically will have Read/Write/Execute
user Y, is the group name that we will give permissions to the folder, Z is the rest of the users
0
 
LVL 1

Assisted Solution

by:Reza_a
Reza_a earned 83 total points
ID: 39891058
chgrp marketing foldername
chmod g=rx foldername
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 5

Assisted Solution

by:Dave Gould
Dave Gould earned 333 total points
ID: 39891300
The example from Laudarch opens the folder to others.

mkdir marketing                                # this will create the folder
chgrp marketinggrp marketing       # This will make the group marketinggroup the group                                                                          owner
chmod 750 marketing                       # owner=rwx, group=r_x, others=no access
0
 

Author Comment

by:jskfan
ID: 39892142
trappa01:
would not this command give ownership to MarketingGroup? which means R+W+E

chgrp marketinggrp marketing       # This will make the group marketinggroup the group                                                                          owner
0
 
LVL 5

Assisted Solution

by:Dave Gould
Dave Gould earned 333 total points
ID: 39892315
No. Imaging that dave is a member of the group admins and he creates a directory called marketing

mkdir marketing
the directory marketing will look something like this (ls -l):
_rwxr_xr_x dave admin marketing     In other words the owner is dave and he has rwx, the group is admin and they have r_x and others also have r_x

dave then types
chgrp marketinggrp marketing      
so now the directory looks like this:
_rwxr_xr_x dave marketinggrp marketing         In other words, dave is still the owner and still has rwx, the members of the group marketinggrp now have r_x as do any others.

So now we need to make sure that the others dont have any access:
chmod 750 marketing                        
so now the directory looks like this:
_rwxr_x_ _ _ dave marketinggrp marketing       dave = owner (rwx) members of marketinggrp have r_x and others have _ _ _ (ie no access)

I hope this is clear
0
 

Author Comment

by:jskfan
ID: 39893661
chgrp marketinggrp marketing  
I see that Chgrp, does not give permission to marketing folder, it just assigns the folder to MarketingGroup, before you give it permissions with Chmod.

Chgrp is like you are telling MarketingGroup "Catch the Marketing" folder , I will tell you what you can do with it.

Chmod, will tell the MarketingGroup what they can do with the folder

I could be wrong
0
 
LVL 5

Assisted Solution

by:Dave Gould
Dave Gould earned 333 total points
ID: 39894038
"I could be wrong" .... but then again....you could be right.

The important thing to keep in mind is that with linux files and folders, we can give 3 levels of access.
1. We can give rights to the owner (a single person) of the file (usually maximum rights)
2. We can give slightly less or different rights to a group of named people. We add these people to a group and assign rights to the group.
3. We decide how anybody else (ie not the owner and not a member of the group) can access the file. Quite often this will be read or execute only .

The file itself has an owner. This is often the person that created the file but I can create a file and designate somebody else as owner with the command chown.
The file belongs to a group too. This is usually the file creators principal group but can be modified using the chgrp command.

The command used to define the levels of access for the owner, group and others is chmod.
0
 

Author Comment

by:jskfan
ID: 39895467
in Windows , you add the group to Access list, then you give the group permissions…

Chgrp groupname Foldername
seems to me like adding the group to ACL
Chmod 750 Foldername is giving permissions to the group specified with Chgrp
0
 
LVL 5

Accepted Solution

by:
Dave Gould earned 333 total points
ID: 39895552
True but dont forget that in windows you can add as many groups as you wish to a file access list. In Linux, you only add one.
0
 

Author Closing Comment

by:jskfan
ID: 39930094
Thank you Guys!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question