What is a Login Shell?

Bash Liste Des Attaques Ovh


A login shell executes:


A login shell is a shell:

  • whose first character of argument zero ($0) is a -
  • or started with the –login or -l option.

Command such as bash, sudo can create shells on the fly. In case, you want to run the login script, you need to run them as login shell with the –login or -l option.

Login and logout script


When bash is invoked as:

it reads and executes commands from the following files in this order:

  • /etc/profile,
  • ~/.bash_profile, # only read by bash
  • ~/.bash_login, # only read by bash
  • and ~/.profile,

The file must exists and be readable.

The –noprofile option may be used when the shell is started to inhibit this behavior.


When a login shell exits, bash reads and executes commands from the files:

  • /etc/logout
  • ~/.bash_logout
  • /etc/bash.bash_logout
  • ~/logout

if the files exists.



In a script, you can test if the shell is a login shell with this predicate.

argv[0][0] == '-'

Discover More
Bash Liste Des Attaques Ovh
Bash - Bash cli

Bash is an sh-compatible a shell that executes commands read: from the standard input or from a file (script). In addition to the single-character shell options documented in the description...
Bash Liste Des Attaques Ovh
Bash - Interactive Shell

An interactive shell is when bash is: started: without non-optionarguments without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)),...
Bash Liste Des Attaques Ovh
Bash - logout - Exit a login shell - (Builtin Command)

logout Exit a login shell.
Linux - su command (switch user)

The su command (switch user) is a part of the user management. To switch to another user, use the su command. This is most commonly used to switch to the root account. su run a shell with substitute...
Bash Liste Des Attaques Ovh
Shell - (Startup|Login) script (.bash_profile, .profile, .login)

The shell login scripts are the script that launch automatically after a login shell and permit to store permanently the values of environment variables. You can found them in two directory: ...
Bash Liste Des Attaques Ovh
What is Sudo? (Switch User and do)

sudo is an command utility that: su: switch user su and do: execute a command In other words, it executes a command as another user. (ie it's a proxy authentication utility) It determines who...

Share this page:
Follow us:
Task Runner