What is BASH?
Here we see two bashers engaged in mortal combat in my old office at NCSSM.
They are bashers because they know how to use BASH (both majored in Computer Science and have secured real jobs right out of college), not because of the terrifying battle you see here.
BASH is a shell, which is a means of communicating commands to the operating system, which acts on those commands. You can think of a shell as being a telephone; you type into this telephone using the keyboard, instead of speaking.
My Mac terminal looks like this. The color scheme is configurable; on some systems, the terimal will have a dark theme. All of this, of course, is configurable via your preferences.
The listener on the other end is your operating system. It hears commands from the shell and replies to them. The operating system can do a wide array of things for you. Here are a few examples.
- Navigate your file system: You can use commands such as
cd
(change directory) to move into a folder (directory in UNIX-speak) orls
("list stuff") to see the contents of a directory - Control what others see: You can use a command name
chmod
to control the visibility of files you own. - Search a file: You can use a string or a textual pattern as a search item in a file and find all instances of that item in a file or a whole batch of files.
- Scripting: You can save a group of commands in a file and execute them in seriatum to accomplish a task.
- Piping and redirection: You can make the output of one command the input of another. It is simple to dump output into a file
Finally, you will have wizard-like nerd creds with your students when they see you using the command line avec panache.
Command-Line Skill
You might ask, "Why learn how to use the command line?" It seems oh-so-20th century!
There are many excellent reasons. Here are a few.
- Cloud computing: This site runs on the cloud. I do not use any graphical interface to interact with it. It is essential that I know how to use a UNIX file system to create and manage files on the site. This is done through the command line interface. Many cloud services require you to work at the command line.
- My Way: The command line interface is highly configurable and you can tailor it to your needs and your routine chores.
- Programmability: Do you ever find yourself doing the same repetitive task over and over again? Wouldn't it be nice to automate it and eliminate a time-suck? The command-line interface is programmable and extensible.
- Programming: it is easy to run programs you write in Python, Java, or C at the command line. You can supply command-line arguments that determine program behavior.
- Data Mining: UNIX commands called filters have two streams: standard input and standard output. The action of filters can be chained, and can, as a result, can do very complex jobs by typing a single line of code. Input can be obtained from files and output can redirected to files. The BASH shell affords a highly efficient way of extracting and processing data from huge files. It also has search facilities that allow you to find needles in haystacks. Using the R programming language and these facilities, I personally helped to design a program trading system that traded 3 million shares a week back in the early '90s.
- VSCode: If you are teaching programming, I hope your students are using this, or if they are on a UNIX system, vim. When you run a program you created in VSCode, the terminal that appears in your session is a BASH shell.
Getting BASH
Here are instructions for installing the LINUX subsystem on Windoze 11. This video will take you through the entire install process and show you how to access your C drive through the BASH terminal. I recommend you use the latest Ubuntu distribution.If you have a Mac, your terminal tool is in
/Applications/Utilities
. MacOSX is a UNIX-based operating
system. This is the principal means I use for managing my files
on my Mac.
If you are running a Linux distro, just search up Terminal and you will have a terminal window running BASH.
Learning Modules
Each of these modules has a link to a file with a more complete description. Each workshop should last about 3 hours.
- The File System Learn how UNIX command work and use this knowledge to navigate and manage your file system and to controls who can see what.
- The vim Editor This is the fastest way to get thoughts in your brain translated into bytes in a computer. I have been using it since 1987.
- Using UNIX Filters to Search and Sort Learn how to marshal large data sets, search them, extract data from them, and store the results.