How do I change groups?

How do I change groups?

If you are a member of more than one group, and would like to run a job on a group that isn't currently your primary group, you will need to specify which group to change to. 

You can see your current group by using the following command.

id  –ng 

You can change groups by using the following command, replacing groupname with the group you want to use. 

newgrp groupname

The change will last for the duration of the login session only; to permanently change your primary group use the online change group tool.
To run a job on a different group, you may use the -A option in your Slurm script, replacing groupname with the group you want to use.

#!/bin/bash -l
#SBATCH -A groupname

If you have enabled trusted X11 forwarding by using the "ssh -Y" command, you must use the following commands to change groups. First, you must obtain the value of the "DISPLAY" variable in the original group.

echo $DISPLAY

Next, you must identify the corresponding xauth cookies by running the following command, replacing displaynumber with the number output from the previous step.

xauth list | grep \:displaynumber

Change to the new group with the "newgrp" command as explained above. Next, run the following commands, replacing displayvalue with the full value of the "DISPLAY" variable as output by the "echo $DISPLAY" command, and replacing xauthlistvalue with one of the lines from the "xauth list" command above.

export DISPLAY=displayvalue

xauth add xauthlistvalue

Note that you must run the "xauth add" command for each line output by the "xauth list" command. Another way to run a program under a different group is to use the "sg" command as shown below, replacing program with the program you'd like to run, and groupname with the name of the group under which you'd like to be running the program.

module load program
sg groupname

Additionally, if you would like to change groups within a Slurm script, you must include the last line in the header, replacing groupname with the name of the group under which you'd like to be running the script.

#!/bin/bash -l
#SBATCH -A groupname

Changing your Primary Group

If the majority of your work has transitioned to a new group, you may want to update your primary group to avoid the additional steps in order to work with that group. You can update your primary group here on myMSI by visiting the Change Group page.

Discover Advanced Computing and Data Solutions at MSI

Our Services
Was this page helpful?
If you have a question about MSI services, please submit a ticket through our Help Desk