DZone
What is bash? Bash is that black screen that normally appears in Linux as the terminal. Bash is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. It was released in 1989 and has been distributed as the Linux and macOS default shell for a long time.
Shells and Modes
The user bash shell can work in interactive and non-interactive login shells.
- Interactive login shell: You log into a remote computer, for example via
ssh
. Alternatively, you drop to a tty on your local machine (Ctrl+Alt+F1) and log in there. - Interactive non-login shell: Open a new terminal.
- Non-interactive non-login shell: Run a script. All scripts run in their own sub shell and this shell is not interactive.
- Non-interactive login shell: This is extremely rare, and you’re unlikely to encounter it. One way of launching one is
echo command | ssh server
. Whenssh
is launched without a command (sossh
instead ofssh command
which will runcommand
on the remote shell) it starts a login shell. If thestdin
of thessh
is not a tty, it starts a non-interactive shell. This is whyecho command | ssh server
will launch a non-interactive login shell. You can also start one withbash -l -c command
.
Comments
Scripts may contain comments. Comments are special statements ignored by the shell
interpreter. They begin with a #
symbol and continue on to the end of the line.
Source: DZone