Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 need to test linux group permissions on a repository. In one shell, how can I temporarily remove one of my group associations?

If my groups are defined as:

 % groups
 foo bar baz

How can I make it so it only returns foo bar without baz?

share|improve this question
up vote 3 down vote accepted

It IS possible.

Check out this code (valid C89, heh) I wrote in 25 mins. Usage example:

whitequark@forth:~/skipgroup$ ls
whitequark@forth:~/skipgroup$ gcc skipgroup.c -o skipgroup
whitequark@forth:~/skipgroup$ sudo chown root:root skipgroup
whitequark@forth:~/skipgroup$ sudo chmod u+s skipgroup
whitequark@forth:~/skipgroup$ groups
whitequark adm dialout cdrom plugdev lpadmin admin sambashare
whitequark@forth:~/skipgroup$ ./skipgroup 
Usage: ./skipgroup <group to remove>
Must be SUID. Launches shell.
whitequark@forth:~/skipgroup$ ./skipgroup cdrom
$ id
uid=1000(whitequark) gid=1000(whitequark)


While it drops privileges as you see on id's output, it MAY BE DANGEROUS. Dixi.

share|improve this answer
wow. If I had root permissions, I'd definitely try this out. – Ross Rogers Jan 21 '10 at 19:20
I think there is really no way to change your group list without root privileges. – whitequark Jan 21 '10 at 19:27

I think that this is not possible, since files (and POSIX ACLs) can specify subtractive rights for certain groups. Allowing people to escape from a group would then be a security hole.

Of course if you have root access, you could simply remove yourself from the group and do

sudo su - $USER
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.