====== Various useful shell tricks ====== ===== How do I switch to a different group I belong to? ===== In unix inspired operating systems one can see whose groups they belong to by using the ''id'' command: [pflorido@pptest-iridium ~]$ id uid=6312(pflorido) gid=34000(clusterusers) groups=34000(clusterusers),6300(hep),6500(npusers),46300(ppguests) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [pflorido@pptest-iridium ~]$ touch testgrp [pflorido@pptest-iridium ~]$ ls -l testgrp -rw-r-----. 1 pflorido clusterusers 0 6 feb 18.09 testgrp The ''gid'' field shows the //primary group//, that is, the first group you belong to and with which one's files will be created. If one wants to switch to another primary group so that the files are created with a different group name, one can use ''newgrp'': [pflorido@pptest-iridium ~]$ newgrp hep uid=6312(pflorido) gid=6300(hep) groups=6300(hep),6500(npusers),34000(clusterusers),46300(ppguests) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023bash-4.1$ touch testnewgrp bash-4.1$ ls -l testnewgrp -rw-r-----. 1 pflorido hep 0 6 feb 18.27 testnewgrp Note that group switching starts another login shell, so you can use ''exit'' to go back to your previous group. bash-4.1$ exit exit [pflorido@pptest-iridium ~]$ id uid=6312(pflorido) gid=34000(clusterusers) groups=34000(clusterusers),6300(hep),6500(npusers),46300(ppguests) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023