Change primary group
Generally, HPCC users need to request root privilege through the
ticket system to change their primary group permanently. However, a user
can also use newgrp
command to change their primary group temporarily to
any one of their groups.
Primary Group Change on Command Line
To change a user's primary group with a command line, simply run
1 |
|
Note that <Group Name>
has to be one of the user's group names. To find
out all group names, please run groups
command:
1 2 |
|
Here, the primary group is "chemistry
", the first group name in the
results. After the execution of newgrp
command, a new shell
session is created and the current environment, including the current
working directory remains the same.
1 2 3 |
|
Note that the primary group is changed to g09. To leave the session, just
run "exit
" command. It will go back to the previous session with the
original primary group (chemistry
).
If a user would like to start the shell session with a new primary
group as though the user just logged in, the optional "-
" flag can
be used
1 2 3 |
|
Using the "-
" flag reinitializes the user's environment and the shell session
starts from the home directory.
Some users might have the issue of losing the header in front of the prompt after executing the command:
1 2 3 |
|
Using source
on the default bashrc file will get it back.
1 2 |
|
Note that, if a job is submitted in the session of a new primary
group, the environment variables of the new primary group will be used by the
job by default instead of the original environment. For more
information, please see --export
in the table of List of Job Specifications page.
Primary Group Change in Job Script
Many HPCC users have more than one research spaces. In a job
running, the user might need their primary group set to be the group of
the research space where the output files are. In order to do this, the
job script can use newgrp
from the beginning of the command lines. For example, an original job script may look like:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
If the job script is submitted in a research space, adding a few lines can make the primary group the same as the group of the research space:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The group name of the research space for job running is
automatically determined in line 7. You can also directly set the
variable "GroupName
" to be the group name of your research space in line 7 if you are sure about jobs running in the research space:
1 |
|
After the group name of the research space is given, the command lines
between line 9 and 16 (inside the two "EOS
") will be run under the
environment of the new primary group (${GroupName}
).
Automatic Primary Group Change after Login
To automatically change your primary group after every login, please submit a ticket to ICER's system administrators with the subject "Membership Changes".
Previously, this page recommended using the PrimaryGroup
powertool in your .bashrc
.
However, this can cause issues when you SSH to other nodes from a development node, and so we no longer recommend using it.