Bash Invocation

Mode Bash Invocation POSIX Shell Invocation
Login Shell -bash
bash -l [Options]
bash --login [Options]
bash --posix --login
Command String bash -c CMD_STRING SHELL ARGS sh -c
Interactive Shell bash [options] sh
Script #!/bin/bash [single word options] #!/bin/sh []
Command File bash [options] file [args] sh [options] file [args]
Command Stream bash [options] -s [ SHELL [args…]] sh [options] file [args]
Restricted Shell bash -p
rbash [options]
sh -p

Login Options

Act as a login shell.
-O login_shell
This option is ignored by bash. Use --login.
--noprofile Do not read the system-wide startup file /etc/profile
Do not read any personal initialization files .bash_profile, .bash_login, or .profile


  1. a allexport -B braceexpand -b notify -C noclobber -c -e errexit -E errtrace -D -f noglob -h hashall -H histexpand -k keyword -m monitor -n noexec -o OPTION -p privileged -P physical -t onecmd -T functrace -u nounset -v verbose -x xtrace

autocd cdable_vars cdspell checkhash checkjobs checkwinsize cmdhist compat31 compat32 compat40 compat41 compat42 compat43 complete_fullquote direxpand dirspell dotglob execfail expand_aliases extdebug extglob extquote failglob force_fignore globasciiranges globstar gnu_errfmt histappend histreedit histverify hostcomplete huponexit inherit_errexit interactive_comments lastpipe lithist

mailwarn no_empty_cmd_completion nocaseglob nocasematch nullglob progcomp promptvars restricted_shell shift_verbose sourcepath xpg_echo


A login shell is started either by:

A login shell need not be interactive. A login shell will:

  1. Set the Shell Option login_shell in BASHOPTS which may not be unset via the shopt builtin
  2. Read & execute commands from profile if it is readable (need not be executable)
  3. Read & execute the first user profile found (searched in the order):
  4. Shell Option --noprofile may be used to suppress this behavior
  5. exit via:
  6. If the huponexit Shell Option was set in BASHOPTS, then bash sends SIGHUP to all jobs in an interactive shell.
  7. Read & execute commands from the readable file .bash_logout
The suspend builtin requires the -f "force" option in a login shell.

POSIX Login Shell


A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the following are disallowed or not performed:

  • changing directories with cd
  • setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV
  • specifying command names containing /
  • specifying a filename containing a / as an argument to the . builtin command
  • specifying a filename containing a slash as an argument to the -p option to the hash builtin command
  • importing function definitions from the shell environment at startup
  • parsing the value of SHELLOPTS from the shell environment at startup
  • redirecting output using the >, >|, <>, >&, &>, and » redirection operators
  • using the exec builtin command to replace the shell with another command
  • adding or deleting builtin commands with the -f and -d options to the enable builtin command
  • using the enable builtin command to enable disabled shell builtins
  • specifying the -p option to the command builtin command
  • turning off restricted mode with set +r or set +o restricted.

These restrictions are enforced after any startup files are read.

When a command that is found to be a shell script is executed (see COMMAND EXECUTION above), rbash turns off any restrictions in the shell spawned to execute the script.

-r If the -r option is present, the shell becomes restricted

               (see RESTRICTED SHELL below).
            The shell becomes restricted (see RESTRICTED SHELL below).

enable [-a] [-dnps] [-f filename] [name …] readonly restricted_shell

                    The shell sets this option if it is started in
                    restricted mode (see RESTRICTED SHELL below).  The
                    value may not be changed.  This is not reset when the
                    startup files are executed, allowing the startup files
                    to discover whether or not a shell is restricted.
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • user/ben_bash/bash/invocation.txt
  • Last modified: 2017/10/18 22:02
  • by ben_bash