Bourne Again SHell (Bash)#
On Ubuntu Linux, your default shell environment is provided by Bash. It's a default for many systems and it's very powerful and very well documented. Because most systems use Bash by default, there is a lot of documentation available for you to find answers. The community of general Linux users who also known Bash well is massive, further increasing the help you have available to you.
We'll talk a bit about some Bash basics, enough for you to continue through this book. A lot of the more advanced features are left to the reader to explore as a learning exercise.
A command is made up of multiple words, the first being the command itself, and the rest of the words being that command’s flags and/or arguments. Here's an example:
Here the command is
ls and the
-l is a flag that is used to change how the command behaves. The
my_script word at the end if an argument given to the
ls command to do its operation against. Given that the
ls command is designed to list files and directories, it's done its job well here.
To better understand how the arguments to a command work, consider our call to
You'll notice we're missing all of the file's information:
-rwx------ 1 michael michael 51 Mar 21 03:12 (we cover what this all means later on.) This is because the
-l flags means to use a "long listing format". Without it,
ls gives us a simple list of files and directories. So we can see that the
-l flag changes the behaviour of the
ls command, from its simple listing to a more complex one.
We also provided an argument,
my_script. What if we run just
ls, without the argument?
We get a list of the files in the current working directory. We can see the
my_script file is there. If we repeat the same thing again, without the
my_script but with the
1 2 3 4 5
We can see that, yet again, we've changed the (default) behaviour of the command
ls, which in tern changed the output from it.