Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been told by numerous people that I shouldn't make each shell I use a login shell. Wether via a TTY, or an Xorg terminal app running bash.. can anyone explain the potential reasoning behind this logic, or debunk it for me? Thanks

share|improve this question
up vote 1 down vote accepted

The first reason that comes to mind is that you should, in general, follow accepted practices. The way a shell is invoked governs the configuration files it reads. From man bash:

   When  bash  is invoked as an interactive login shell,
   or  as  a  non-interactive  shell  with  the  --login
   option, it first reads and executes commands from the
   file /etc/profile, if that file exists.  After  read‐
   ing   that   file,   it  looks  for  ~/.bash_profile,
   ~/.bash_login, and ~/.profile,  in  that  order,  and
   reads  and  executes commands from the first one that
   exists and is readable.  The --noprofile  option  may
   be  used  when  the  shell is started to inhibit this

   When a login shell exits,  bash  reads  and  executes
   commands from the file ~/.bash_logout, if it exists.


   When  an  interactive shell that is not a login shell
   is started, bash reads  and  executes  commands  from
   /etc/bash.bashrc and ~/.bashrc, if these files exist.
   This may be inhibited by  using  the  --norc  option.
   The  --rcfile file option will force bash to read and
   execute    commands    from    file    instead     of
   /etc/bash.bashrc and ~/.bashrc.

Most distributions will place global aliases, variables and shell options in /etc/bash.bashrc because they are configured to make most shells (terminals etc) interactive, non-login shells. Therefore, if you switch to using login shells, you will loose all these settings. This could conceivable cause problems downstream if, for example, certain global variables have not been set correctly etc.

In addition, the default setup is to run a login shell when you log in and non-login shells thereafter. This makes it easy to set up environment variables or simple jobs that should be executed once in the login shell's setup files (e.g ~/.profile), The advantage is that these will only be run once, when you log in. If you make all your shells login shells then these commands will be executed multiple times which is i) not elegant and ii) can slow down your system if these commands are resource intensive.

Finally, it often desired to have different environments set up if the user is logging in through ssh for example and if she is physically present and opening a terminal. By making all your shells login shells, you lose the ability to make that distinction.

Now, it can't be as bad as all that since, if I understand correctly, OSX's terminal app starts login shells by default. However, OSX has been designed that way so the potential problems I've mentioned have presumably been taken care of. That will not be the case if you modify your Linux setup to do so yourself.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .