Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

folder permissions in Linux

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
jskfan
Asked:
jskfan
6 Solutions
 
Archzilon Eshun-DaviesCommented:
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
 
jskfanAuthor Commented:
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
 
Reza_aCommented:
chgrp marketing foldername
chmod g=rx foldername
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
Dave GouldCommented:
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
 
jskfanAuthor Commented:
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
 
Dave GouldCommented:
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
 
jskfanAuthor Commented:
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
 
Dave GouldCommented:
"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
 
jskfanAuthor Commented:
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
 
Dave GouldCommented:
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
 
jskfanAuthor Commented:
Thank you Guys!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now