Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was asked to add group-wrx permissions to a directory in another user's home folder.

I believe what I should do is run `chmod 771 -R directoryname' in the parent directory. What I can't find anywhere on the tubes is how to specify WHICH group I want to give these permissions to. I'm personally in a number of groups, and in a bunch I don't know about as root.

In case it matters, The system is running Redhat 5.4.

share|improve this question
    
Why the downvotes? Poor phrasing? Miscategorized? Insufficient information? Dumb question that anyone would know the answer to? I'll be able to improve my question with just a little insight. –  malenkylizards Sep 30 '11 at 17:51
    
I don't think it's a bad question, but it's not one that belongs here. I am also perplexed as to why you got downvotes. –  Omnifarious Sep 30 '11 at 17:58
add comment

migrated from stackoverflow.com Sep 30 '11 at 18:00

This question came from our site for professional and enthusiast programmers.

2 Answers

Every file on an ext filesystem has:

  1. An owner user
  2. An owner group
  3. Permissions for this user, this group and everybody else.

If you're setting rwx group permissions on a file, only the owner group of that file can read/write/execute it. You can, though, change user and owner with:

chown username file1 file2 ...
chown -R username somedir
chgrp groupname file1 file2 ....
chgrp -R groupname somedir
chown username:groupname file1 file2 ...

There are different implementations for extended filesystem privileges, i.e. ACLs (Access Control Lists) on Mac OS X, but since I'm no Linux expert, you should probably ask in Server Fault for that.

share|improve this answer
    
"so if you're setting rwx group permissions on a file, only the owner group of that file can read/write/execute it" i realize, that may be misleading, first of all if you are the owner user, of course the owner user rules take precedence, if your neither the owner user, nor in the owner group, the rules for others apply. –  Marian Theisen Sep 30 '11 at 17:53
add comment

The chmod() system call, and by extension the chmod program, does not affect the group of a file or directory (or other type of file: block special, character special, socket, ... symlink is something of a special case). So, the group to which the permission is given will be the group to which the file or directory belongs.

To add group rwx permissions, you should use:

chmod -R g+rwx DirectoryName

However, this adds the permissions to every file as well as every directory, and not all files should be executable. Personally, I'd be very unhappy if someone provided group write permission on all (or any) of my directories, but that's another story.

To affect directories only, use find instead:

find DirectoryName -type d -exec chmod g+rwx {} +

(The + notation is POSIX 2008; not all Unix systems support it, though Linux does.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.