What does "Login shell" do?

6,780

"Login shell" runs the usual shell (zsh or bash) in login mode, in which the shell processes additional configuration files – such as .zlogin or .bash_profile. Chances are that those files have too many unnecessary commands – try to keep them as lightweight as possible.

You can try running zsh -l and comparing it with regular zsh. (While -l is not a standard "login mode" switch, it's pretty common.)


(Though IMHO, it is a bit odd for a terminal app to even run shells in "login mode" at all… It sort of defeats the whole idea of being able to configure different startup commands.)

Share:
6,780

Related videos on Youtube

xhg
Author by

xhg

do some programming

Updated on September 18, 2022

Comments

  • xhg
    xhg almost 2 years

    Recently I experience slow terminal launch time, so I looked into it and found an interesting thing. I am using iTerm on MacBook. There is an option choosing the default behavior:

    Login shell or zsh

    If I chose "Login shell", it will prompt Last login: Fri Mar 24 17:27:28 on ttys007 (left side below); if I chose "zsh", it won't prompt anything and launch time is very fast (right side below).

    difference between login shell and zsh

    The default shell I use is zsh, I wonder what's happening inside "login shell" and why it is so slow compared to pure zsh.

  • xhg
    xhg over 7 years
    I think your answer helped me out of my problem. There is one line [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* which after I commented out "login shell" became incredibly fast. Thanks dude
  • user1686
    user1686 over 7 years
    Yeah, rvm was horribly slow the last time I tried it as well. But in general, anything that defines functions ought to go to the main config file – .zshrc or .bashrc – not to the "login" one.
  • xhg
    xhg over 7 years
    thx for your advice. I cannot remember why it is there