Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Terminal.app has the setting "Shells open with:" with the option "Default login shell (/usr/bin/login)", and "Command (complete path)" that by default contains "/usr/bin/bash". The dafault option for that setting is "Default login shell (/usr/bin/login)".

What is the difference between /usr/bin/login, and /usr/bin/bash? Which one should be choose as default shell?

share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

A practical difference is in the way that the resulting shell environment reads its initial configuration settings.

/usr/bin/login forks a login shell. I think that it invokes the authentication process, but you may not see any visible authentication interaction if you're already logged in. And, of course, if your login shell is not bash, login will invoke it instead of bash.

bash is a shell that knows whether it was invoked as a login shell or not. A bash login shell reads .bash_profile or .bash_login or .profile -- only one, in that order of preference. A non-login shell will not read a .profile but will read from .bashrc. This is normal bash behavior under modern *nix platforms, but it can lead to difficult to detect weird behaviors if you don't understand what's going on.

For instance, you can open a "login" shell via Terminal, and get one set of environmental variables (say, from your .profile), then type "bash" and get a completely different set of variables (from the .bashrc, plus any variables that were exported, minus those which were not). In particular, PATH can get mangled with repeated or missing entries.

share|improve this answer
add comment

/usr/bin/login is not a shell; it is a program used to login to a system. It manages the process of logging in to a system. As a user of a properly configured system, you should never have to concern yourself with /usr/bin/login. If you are curious about it anyway, read

man login

A shell is run after the login process has completed. It gives the user a text-based command-line interface to the facilities of the operating system, including running other programs. /usr/bin/bash is a good choice for a default shell. You can read more about bash by executing

man bash

Both of those man commands may be executed at the shell prompt.

share|improve this answer
    
Terminal.app has usr/bin/login selected as default shell by default; that's the reason I am asking. –  kiamlaluno Jun 29 '10 at 8:55
    
Put that way, I don't know the answer. I don't use a Mac myself but I just experimented with the Terminal preferences on my wife's MacBook Pro. The only difference I could see between those two settings, using "ps -fu username", was that selecting bash caused "-q" to be added to the arguments to login. I thought that the shell of a second Terminal would be a descendant of the first login if /usr/bin/login was not the default shell, but I couldn't figure out how to open a second Terminal. –  garyjohn Jun 29 '10 at 16:25
add comment

They are two very different things, and only commonality is that both usually run at the beginning of loggin in a user and both run a configuration dot-file (.login and .bashrc) that are essencially shell scripts. In addition bash, like many modern shells, also allows you to switch between users, which is one of the main purposes of login

In detail:

login is a program used to log in a user, at the end of which the shell (aka command line interpreter) is executed.

login only knows how to do one thing - log in a user (athenticate using username/password, set some environmental variables like TERM and PATH, and execute a couple of on-login admin tasks - see the link for details.

A unix shell (of which bash is an example of) is a command line interpreter coupled with a script interpreter, and its function is to accept input (from the user or supplied programmatically) and execute requested commands.

As far as I'm aware, login can not be used as a shell at all as it has no functionality of a command line interpreter.

share|improve this answer
    
See what I added to the original question. Terminal.app does allow to set login as default login, which is the default value. –  kiamlaluno Jun 29 '10 at 8:53
add comment
% man login

 login  is  used  when  signing  onto  a system.  It can also be used to
   switch from one user to another at any time (most  modern  shells  have
   support for this feature built into them, however).


% man bash

  Bash  is  an  sh-compatible  command language interpreter that executes
   commands read from the standard input or from a file.

so, if you have to pick one shell out of your two given choices, it is clearly bash.

share|improve this answer
add comment

/usr/bin/bash

This is built linux kernel in Mac OS. Then I think it is almost the same when you get the command in linux. The default shell should be bash.

share|improve this answer
5  
I don't get what your first sentence is supposed to mean. –  Ignacio Vazquez-Abrams Jun 29 '10 at 2:37
add comment

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.