Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Per default xterm starts an interactive shell. But you can also configure it to start an interactive login-shell.

That means that with starting an xterm you get the same kind of shell like logging in via ssh/virtual console/su.

What are the advantages/disadvantages configuring a login-shell in xterm?

I can think of:

  • uptime, w, last etc. report as many users as xterm's are open. (advantage?)
  • bash only sources .login, .profile, /etc/profile.d when started as login-shell
  • zsh has similar files which it reads when started as login-shell - but on my system they are empty by default

Related xterm man page section:

   -ls     This  option  indicates  that  the shell that is started in the
           xterm window will be a login shell (i.e., the  first  character
           of  argv[0]  will  be  a  dash, indicating to the shell that it
           should read the user's .login or .profile).

There is also a resource:

  loginShell (class LoginShell)
           Specifies whether or not the shell to  be  run  in  the  window
           should be started as a login shell.  The default is “false.”
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Running a login shell in the terminal will execute any program you put in your .profile, even if you'd expect that program to run only once per session (for example, ssh-agent and other keyrings). Running a login shell will overwrite environment variables that you've set in your session or in the terminal's parent process.

The biggest problem people who run a login shell in terminals experience is that they usually don't set their environment variables when they log into the GUI. The drawback of this is that the environment variables are thus only available in programs started from a terminal, not from programs directly started through the GUI. If you do set your environment variables at login time, setting them again in each terminal is at best pointless and sometimes a problem as seen above.

See also Difference between .bashrc and .bash_profile, Alternative to .bashrc, and quite a few questions I've seen on Stack Exchange that would have been avoided if the asker had set environment variables per session.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.