Skip to end of metadata
Go to start of metadata

Introduction

When you log into a Unix machine or submit a batch job, your commands are interpreted by a login shell. Each time you log in or open a shell, several configuration files are executed. These files define variables, set functions, etc., depending on the particular shell.

During the initial registration the login shell is set by the system administrator and some of the default configuration files are copied into your $HOME directory. Some configuration files are compulsory, while others can be customized. In particular the .user_* files are intended for your own settings. Please do not remove calls or links to shared configuration files, as without them it cannot be guaranteed that your environment will be correct after system changes. Whenever you make changes to your configuration files, do not forget to execute them.

In additions to configurations files, the user's environment can be modified with the Modules Environment, on ecgate and HPCF, e.g. to make available software packages or specific compiler versions.

Available shells

The only command interpreters supported are the Bash (bash) and Korn shell (ksh). Other shells (Bourne, tcsh, csh) may be available but are not fully supported.

Tables 1, 2 and 3 list the configuration files for bash and ksh. The .user_* files are only executed if present.

To change the default shell you have to execute changesh

user@machine:~> changesh
Enter your user id: user

Your current shell is: /bin/bash
Enter new shell [/bin/ksh, /bin/bash]: 

Table 1: Bash shell configuration files in order of execution.

file nameexecution atcomment
/etc/profile
each login and job executionunchangeable system-wide environment settings
$HOME/.profile
each login and job executionunchangeable local environment settings, link to a shared file. It will load .user_profile
$HOME/.user_profile
called by .profilesuitable for your own settings (e.g. PATH)
$HOME/.bash_profile
each bash startup and job execution

unchangeable link to general files. I will load:

.bashrc and .user_bashrc if they exist

$HOME/.bashrc
$HOME/.user_bashrc
each bash startup and job executionsuitable for your own settings
$HOME/.bash_logout
each logout and end of jobyour own setings
~ecmwf/share/.epilog
each logout and end of jobunchangeable script that will remove of temporary directories
$HOME/.user_epilog
each logout and end of jobyour own logout procedure

Table 2: Korn shell configuration files in order of execution.

file nameexecution atcomment
/etc/profile
each login and job executionunchangeable system-wide environment settings
$HOME/.profile
each login and job executionlocal environment settings, link to a shared file
$HOME/.user_profile
called by .profilesuitable for your own settings (e.g. PATH)
$HOME/.kshrc
each ksh startupshared setups for ksh users, link to a shared file
$HOME/.user_kshrc
called by .kshrcsuitable for your own settings (aliases, variables, functions)
$HOME/.user_epilog
each logout and end of jobyour own logout procedure
~ecmwf/share/.epilog
each logout and end of jobremoval of temporary directories

Table 3: C shell configuration files in order of execution.

file nameexecution atcomment
/etc/cshrceach loginunchangeable system-wide csh initialization
$HOME/.cshrceach csh startupsuitable for your own settings
$HOME/.logineach loginown settings (changing the shell)
$HOME/.logouteach logoutremoval of temporary directories, link to a shared file
$HOME/.user_logoutcalled by .logoutown logout procedure, link to a shared file

4 Comments

  1. You may want to set up aliases in the file $HOME/.user_profile for time critical 2 users on the Cray HPC systems, as some system's aliases, e.g. 'll', will overwrite the aliases defined with the same names in the file $HOME/.user_kshrc.

  2. Please make table 1 (Bash conf') wider. I also have some other remarks.

    1. in tables, I suppose "login" implies "interactive login" because shells mans say /etc/profile and .profile are sourced in this case (interactive and login). But nevermind: I don't know what a non interactive login shell is (and how to get it)!
    2. for the Bash example, "Bash startup" means executing the "bash" command itself in some non login shell (myps1> bash), which I never do on my own, but that some of SLURM commands do, like salloc for instance.
    3. what "job execution" means? simply executing a shell script? or executing a shell script in batch mode, with SLURM for instance? Is there any distinction in shell's behaviour between interactive and batch mode for running a script? Because Bash man says executing a shell script sources no file, except the one in BASH_ENV variable, if defined.
    4. what is the need for .user_* files? Why .[bash_]profile and .bashrc are not part of system-wide /etc/profile and /etc/bashrc files?

    In my various HOMEs on Meteo France machines, I turned out to nearly swap .profile and .bashrc, assuming that profile files are for interactive mode and bashrc files are for environment. This is quite contrary to what is generally admitted (cf .profile/.bashrc headings), but seems more consistent with Bash man, excepted for the interactive/non login case (salloc example).

    For me, environment (.bashrc) means env. variables, while interactive (part of .profile) means functions and aliases (not exported).

    1. Dear Harold,

      I will try to answer your questions:

      1. Login means option "-l" in the shell. You could have a non-interactive login shell, for example, running a script with a  shebang

        #!/bin/bash -l
      2. Bash startup means any bash invocation, being interactive or non-interactive, login or non-login
      3. By job execution we refer to a batch job run through the batch system, such as SLURM.
      4. We use .user_* files because their original counterparts are actually links to shared files for everyone. That allows us to share the same user setup across many different computing platforms at ECMWF with centralised management.


  3. I had difficulty logging in today, and I noticed that Service Desk's solution was to delete my $HOME/.bashrc. This file contained the initialisation for Anaconda. Is it recommended to not have a .bashrc file at all?

    It's not really a problem as I can just source the conda initialization file before I use any conda commands.


    EDIT: I think I misread. It was the .Xauthority file causing the problem, not .bashrc. So it's definitely okay to modify the .bashrc file?