The Bourne Again Shell (BASH) is a based on the Bourne Shell. But what’s a Shell? Definition: A shell is a command interpreter and is a layer between system function calls and the user. Allowing the execution of quick commands and running prewritten scrips.
BASH doesn’t really operate anything on your system, it’s only an interface that runs in your terminal and executes statements via either the BASH prompt or scripts. It also has two types of run-mode:
- Interactive: this is when the user writes commands and they execute
- Non-interactive: is when it executes a prewritten and stored script, executing the commands within, usually, sequentially.
The Shell prompt’s end: The $
at the beginning of a line represents your BASH prompt. Traditionally, a shell prompt either ends with $
, %
or #
. If it ends with $
, this indicates a shell that’s compatible with the Bourne shell (such as a POSIX shell, or a Korn shell, or Bash). If it ends with %, this indicates a C shell (csh or tcsh). If it ends with #
, this indicates that the shell is running as the system’s superuser (root) and caution is advised.
Commands
- The manual command
man
opens documentation known as ‘man files’ on various topics. Syntax isman <topicName>
tryman bash
to see built in commands. - The
help <command>
command is also useful and can provide brief summary on what a command does. - To see the files in a current directory
ls
. - Create files using
touch fileName
, can add the names of as many files as you want to create in one touch command. Look into how Unix handles file types, it doesn’t. All files are the same what matters is the meta data in the files header. This reddit thread explains well. - Remove a file using
rm fileName
or using the wildcard*
to wipe a directory.
$ ls # There are two files in the current directory.
The secret voice in your head.mp3 secret
$ rm The secret voice in your head.mp3 # Executes rm with 6 arguments; not 1!
rm: cannot remove `The': No such file or directory
rm: cannot remove `voice': No such file or directory
rm: cannot remove `in': No such file or directory
rm: cannot remove `your': No such file or directory
rm: cannot remove `head.mp3': No such file or directory
$ ls # List files in the current directory: It is still there.
The secret voice in your head.mp3 # But your file 'secret' is now gone!
Always take heed of your file names being in quotation marks when deleting files!!!
- The
echo
command prints its arguments to the standard output (often our terminal). That’s whyecho "$BASH_VERSION"
prints our BASH version : ).