Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some users in a group called aa and I need to give them the rights to write to a folder which is currently tomcat:tomcatdeploy.

The straightforward way to do this is to add all the users to the tomcatdeploy group, one-by-one.

Is it possible to say that members of group aa are also automatically members of tomcatdeploy by somehow adding the aa group to the tomcatdeploy group?

Or is that trying to push the UNIX permissions scheme too far?

share|improve this question
up vote 7 down vote accepted

You could use the lid command to get a list of users in aa, and the loop over that list to add them to tomcatdeploy:

for u in $(lid -g -n aa); do usermod -a -G tomcatdeploy $u; done
share|improve this answer
for u in $(lid -g -n aa); do usermod -a -G tomcatdeploy $u; done (I suppose you meant $u in usermod, not just u) – asoundmove Feb 25 '11 at 21:49
Good catch! I just fixed the code in my answer. – Justin Ethier Feb 25 '11 at 22:09

You didn't mention what platform you are on, but a Linux system from within the last 5 years (or more, probably) supports ACLs, in addition to the traditional Unix file system permissions. By using ACLs, you can add the 2nd group to the directory with write access:

$ setfacl -m group:2ndtomcatdeploy:rwx target_directory

You can use getfacl to display the ACLs and ls -l will show a '+' at the end of the usual symbolic mode string.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.