LogIn shells

From Linuxintro
(Redirected from Login shells)

A login shell is a shell to which you log in via console or ssh. This is also true if you have not given your username and password due to passwordless login. If you change your user with the su or sux command, this is no login shell. If you log in using the display manager and start a shell, this is no log in shell. If you call bash -login, you are in a login shell (bash), although you did not login at all.

When you start a login shell, login-scripts will be started, and if you start a shell that is not a login shell, other scripts will be started.

What is a login shell

action log-in-shell
you enter a computer with ssh, typing username and password yes
you enter a computer with ssh using passwordless login yes
you enter a computer by logging in to the Window Manager, using username and password. Then you open konsole by clicking on it. no
you open a console and type su -, then password yes
you open a console and type bash - yes

Example

Here is an example showing which login process calls what scripts:

tweedleburg:~ # su - tstaerk
This is /etc/profile.d/run-on-login-for-all-sh-users.sh
This is /etc/bash.bashrc
This is .bashrc
this is .bash_profile
tstaerk@tweedleburg:~> exit
logout
tweedleburg:~ # su tstaerk
This is /etc/bash.bashrc
This is .bashrc
tstaerk@tweedleburg:/mnt/barracuda/root> exit
exit
tweedleburg:~ # ssh tstaerk@localhost
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Sun Jan 12 09:42:47 2014 from localhost
Have a lot of fun...
This is /etc/profile.d/run-on-login-for-all-sh-users.sh
This is /etc/bash.bashrc
This is .bashrc
this is .bash_profile
tstaerk@tweedleburg:~> cat /etc/motd
Have a lot of fun...
tstaerk@tweedleburg:~> exit

Files

The scripts that you can change to control the behavior when logging in are as follows:

  • /etc/profile.d/*.sh
These scripts will be executed on login to sh shell for all users
  • /etc/profile.d/*.bash
These scripts will be executed on login to bash shell for all users
  • /etc/profile.d/*.tcsh
These scripts will be executed on login to tcsh shell for all users
  • /etc/profile.d/*.csh
These scripts will be executed on login to csh shell for all users
  • /etc/bash.bashrc
This script will be executed for all users that start bash shell
  • ~/.bash_profile
This script is specific for the user. It is situated in their home directory. The script is executed on login to bash.
  • ~/.bashrc
This script is specific for the user. It is situated in their home directory. The script is executed on start of bash.
  • ~/.alias
sourced by .bashrc if it exists
  • /etc/motd
displayed for login shells by the login process as a greeting

See also