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. When ssh is launched without a command (so ssh instead of ssh command which will run command on the remote shell) it starts a login shell. If the stdin of the ssh is not a tty, it starts a non-interactive shell. This is why echo command | ssh server will launch a non-interactive login shell. You can also start one with bash -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