Solved

folder permissions in Linux

Posted on 2014-02-26
11
382 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
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
 
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now