Tuesday, February 23, 2021

Bash

In today's lesson I introduced the concept of a shell and specifically Bash to my students. What I found to be interesting whilst preparing for the class was reading through the Bash Reference Manual. I still have a lot to learn when it comes to this topic as a whole.

In summary this is what I talked about:

What is a shell?

A shell is a user interface that accepts text and symbols from a user to execute commands on a computer. These commands are usually low level utilities that relate to files or networking. A shell is also a programming language in it's own right.

How do you interact with the shell?

Shells can be used interactively in a terminal via keyboard input. Shells can also be used non interactively where it executes commands from a file. A term that's often used to describe executing these kind of commands from a file is shell scripting.

What is Bash?

Bash is a shell that is default to most Linux distributions. It was also the default shell on macOS until very recently (2019). It now ships with the zsh shell but this can be changed back to Bash. The command to do that is:

chsh -s /bin/bash

sh was the original shell, it shipped with an early version of the Unix operating system. Bash is essentially the modern equivalent of sh and is compatible with it.

What is Unix?

Unix is an old operating system that's had a significant impact on a lot of operating systems we use today. It's often regarded as an originator in terms of file system hierarchy and permissions. There are many different forks of Unix. In this chart you can see how macOS and Linux distributions all derive from Unix.

Does Windows ship with the Unix utilities?

Windows doesn't inherit all the command line tools from Unix therefore it's incompatible with some of the things we do in this course. It especially will break the way some ruby gems work. Windows is awesome for doing a lot of development work (C#, .NET) but it's not great for what we do.

What are some of the Bash commands you use everyday?

Here is a quick list.

cd <directory>
cd ..
pwd
ls
touch
mkdir
mv
cp
rm

For a full list of the commands available check out this list.

What's a good reference for learning about the different flags (like ls -a) related to terminal commands?

Explain Shell is an awesome website where you can paste in terminal commands and you'll get some information specifically on what each flag is for.

What's the .bash_profile and .bashrc?

These are configuration files for making Bash work a certain way. If you were to use the zsh shell you'd use a .zshrc.