Solved

folder permissions in Linux

Posted on 2014-02-26
11
401 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

623 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