My username is a member of multiple groups. How do I work with multiple groups?

MSI Groups

Your MSI user account is associated with the PI who created the account; this PI's group is known as your primary group. You can have your user account added to additional “secondary” groups as well. This allows you to have access to another group’s files, quota space, and SUs, which is useful if you are working with another PI on a project. To have your account added to Goldy Gopher’s group have Goldy (the PI) email help@msi.umn.edu with a request to have your user account added to the gopherg group.

Quickstart

Add these commands to your .bashrc file (located in your home directory). The rest of this document explains these commands in detail. Replace “gopherg” with the name of your secondary group:

# define an environment variable to hold the active group
export MYGROUP=$(id -gn)

# group follows along with ssh
function ssg ()
{
\ssh $@ -t "newgrp \- $MYGROUP"
}
alias ssh=ssg

# switch groups by typing the name of the group (repeat this line for additional secondary groups)
# Replace gopherg with the name of your secondary group!
alias gopherg="newgrp \- gopherg"

# make new jobs run as, and bill SUs to,  your active group
alias qsub="qsub -A $MYGROUP -W group_list=$MYGROUP"
alias isub='isub -A $MYGROUP -W group_list=$MYGROUP'

# Add your active group to your command prompt (and add some color)
GROUP_NAME=$(id -gn)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;36m\]\u-$GROUP_NAME@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ '

Switching Groups

When you log in to MSI your active group is your primary group. To switch to the gopherg group use the newgrp command:

$ newgrp - gopherg

Note

The dash in the newgroup command causes your environment to be reinitialized which bumps you back to your home directory (among other things), but is neccessary for the .bashrc modifications listed on this page to work. If you omit the dash and run “newgrp gopherg” you will stay in your current directory and keep your current environment, but alias definitions are lost.

To make it easier to switch to the group gopherg you can add an alias to your .bashrc:

alias gopherg="newgrp \- gopherg"

Then you can switch to the group just by typing its name:

$ gopherg

To switch back to your primary account type “exit” or press control-d

Files

When you create new files they will be owned by your active group. If your active group is not gopherg and you create files anywhere in gopherg’s group directory the filesystem will immediately change the group ownership of the files to gopherg. This process occasionally fails resulting in a “Disk quota exceeded” error, so it is recommended you first change your active group before creating files in another group’s home directory.

PBS Jobs

PBS jobs submitted with the qsub command draw SUs from your primary account, regardless of what your current active group is. To charge SUs to group gopherg you can use “#PBS -A gopherg” in the pbs script, or add “-A gopherg” to the qsub command line.

PBS jobs execute as your primary group, regardless of what your current active group is. This can result in the job encountering file permission and quota problems. To have a job execute as group gopherg use “#PBS -W group_list=gopherg” in the pbs script, or add “-W group_list=gopherg” to the qsub command line. If you always want jobs to bill SUs to, and run as, your current active group add these lines to your .bashrc file:

export MYGROUP=$(id -gn)
alias qsub="qsub -A $MYGROUP -W group_list=$MYGROUP"
alias isub="isub -A $MYGROUP -W group_list=$MYGROUP"

Note

You can always override aliases and run the original command by adding a “\” at the front of the command when you use it:

$ \qsub script.pbs

SSH

When you use ssh to connect to another MSI computer your active group on the new computer will be your primary group, regardless of what your active group was on the previous computer. To have your active group follow you around add these lines to your .bashrc file:

export MYGROUP=$(id -gn)
function ssg ()
{
\ssh $@ -t "newgrp \- $MYGROUP"
}
alias ssh=ssg

Command-Prompt

The default command-line prompt shows your username. Add these lines to your .bashrc to have the username and active group displayed so it’s easy to see what group you are working in:

# Set the command prompt.
GROUP_NAME=$(id -gn)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;36m\]\u-$GROUP_NAME@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ '