Bash - Bash cli


Bash is an sh-compatible a shell that executes commands read:

With docker, you can have a bash easily on unbutu with the following command

docker run -t -i ubuntu /bin/bash


bash [multiple character options] [single character options] [arguments]

Single character Options

In addition to the single-character shell options documented in the description of the set builtin command, bash interprets the following options when it is invoked:

Options Short Description Long Description
-c string String Command commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
-s Standard Input Command If the -s option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell.
-i Interactive shell
-l Login Shell
-r Restricted
-D A list of all double-quoted strings preceded by $ is printed on the standard output. These are the strings that are subject to language translation when the current locale is not C or POSIX. This implies the -n option; no commands will be executed.
[-+]O [shopt_option] shopt invocation shopt_option is one of the shell options accepted by the shopt builtin command. -O sets the value of that option; +O unsets it.
End of options processing disables further option processing and treat further arguments as file names and arguments. An argument of - is equivalent to –.

Multi-character Options

The multi-character options must appear on the command line before the single-character options to be recognized.

Options Short Description Long Description
–debugger Arrange for the debugger profile to be executed before the shell starts. Turns on extended debugging mode (see the description of the extdebug option to the shopt builtin below) and shell function tracing (see the description of the -o functrace option to the set builtin below).
–dump-po-strings Equivalent to -D with gettext po (portable object) Equivalent to -D, but the output is in the GNU gettext po (portable object) file format.
–dump-strings Equivalent to -D
–help Help Display a usage message on standard output and exit successfully.
–init-file file
–rcfile file Execute commands from file instead of the standard personal initialization file ~/.bashrc if the shell is interactive
–login Equivalent to -l
–noediting Do not use the GNU readline library Do not use the GNU readline library to read command lines when the shell is interactive.
–noprofile no startup script Do not read either the system-wide startup file /etc/profile or any of the personal initialization files ~/.bash_profile, ~/.bash_login, or ~/.profile. By default, bash reads these files when it is invoked as a login shell
–norc no personal initialization file Do not read and execute the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.
–posix posix beahviour Change the behavior of bash where the default operation differs from the POSIX standard to match the standard (posix mode).
–restricted Restricted shell The shell becomes restricted
–rpm-requires List of required rpm files This files are required for the shell script to run.
–verbose Equivalent to -v
–version Version



If arguments remain after option processing, and neither the -c nor the -s option has been supplied, the first argument is assumed to be the name of a file containing shell commands.

If bash is invoked in this fashion, $0 is set to the name of the file, and the positional parameters are set to the remaining arguments. Bash reads and executes commands from this file, then exits.

An attempt is first made to open the file in the current directory, and, if no file is found, then the shell searches the directories in PATH for the script.

Powered by ComboStrap