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

I believe I should run chmod 771 -R directoryname in the parent directory. I can't find 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 Red Hat Linux 5.4.


2 Answers 2


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.)

  • 2
    If you use +X (capital X) you will only add execute (or 'search') permission if the file is a directory or already had execute permission for some user. linux.die.net/man/1/chmod
    – David
    Apr 6, 2016 at 18:03
  • @Dave: chmod +X is supported on BSD (Mac OS X) too, it seems. Careful scrutiny of POSIX chmod indicates that +X is a POSIX feature after all: The perm symbol X shall represent the execute/search portion of the file mode bits if the file is a directory or if the current (unmodified) file mode bits have at least one of the execute bits (S_IXUSR, S_IXGRP, or S_IXOTH) set. It shall be ignored if the file is not a directory and none of the execute bits are set in the current file mode bits. Note the Rationale below. Apr 6, 2016 at 18:17

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.

  • 1
    "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, 2011 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy