Chapter 3 Bash
3.1 Goal
Gain an understanding of what bash is and what it can do for you
3.2 Learning Objectives
After going through this chapter, students should be able to:
- Explain the difference between the command line and bash
- List advantages of bash over a graphical user interface (GUI)
3.3 What is bash
In order to understand what bash is, we first need to define what the command line is. The command line is the text interface with your computer that is brought up when you run terminal
or another similar program. In computers with no graphical interface, the command line is the only way to interact with the computer.
Bash is a command line interpreter. There are several different interpreters, but bash is quite common and the default on the provided CMDB laptops. Bash allows you to:
- navigate through the filesystem
- interact with files by creating, editing, examining, moving, or deleting them
- run built-in tools
- perform some basic logical operations, i.e. a simple form of programming
Though it lacks some of the features of other programming languages (which we will discuss in the Chapter 5), bash is similar in that it executes commands. Bash is particularly specialized for file system navigation and management, networking, and administration tasks, such as setting up the environment (what programs are available to be used), and chaining together code written in other languages.
3.4 Bash vs. a graphical user interface (GUI)
While all of us are very familiar with GUIs (e.g. macOSX or windows, excel, gimp, photoshop), many will be less (or not) familiar with getting the same or more functionality out of the command line through bash. Some of the most powerful features of using bash are text manipulation and performing repetitive tasks. While on a GUI there is not an easy way to perform the same task or set of tasks repeatedly, bash allows you to create a script that can easily handle even complex sets of tasks repeated on each input.
The biggest disadvantage of the command line and bash compared to a GUI is the learning curve. Many people are nervous to use the command line because of its unfamiliarity, but with a few simple commands, you will be using bash with ease.