Bash Terminal

kyle kelly
3 min readJun 24, 2019

--

Bash is a Unix shell and a command language. It was written by Brain Fox as a free alternative to the Bourne shell. It is typically the default shell for Linux and macOS. The shell is typically the command line where the commands are generally structured as someCommand and often there is one or several someArgument.

The command line will save you loads of time. It’s meant for traversing through your file system faster and is intended to make your life easier. Don’t be intimidated by it! Also, there are typically scripts that allow you to download applications such as Spotify, Steam, etc. I know on my Linux machine this makes my life much easier because sometimes it can get a little difficult downloading the application from the source.

There are a few commands that you should get extremely familiar with once you start using the command line.

ls

This command will list all the files in your current working directory and allow you to see what is contained and where you can ‘cd’ into next.

cd

This command will allow you to change your working directory and making it easy to traverse through the file system faster.

mkdir

This will allow you to create a new folder within the directory that you are currently in.

touch

This is similar to mkdir, but instead of making a new folder, touch will make a new file for you within the current directory that you are in.

.bashrc

.bashrc is a shell script that bash runs whenever it is started interactively. It initializes the shell session. You typically want to put commands in here that will run right when the shell session is started. For instance, if you have nvm installed you will typically find the command in your .bashrc that runs it every time your terminal is launched. You can also add customization in here as well to customize your terminal. Typically this is where you would put your aliases that way you’ll always have access to them.

The .bashrc also allows for you to use if else statements and functions within your terminal. For example, in my terminal, I have a lot of customization to it that I want always executed when a new terminal loads.

if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
fortune | cowsay | lolcat
fi

This is an if statement within my terminal to run 3 programs for each time my terminal is initialized. When I open my terminal up, you’ll see it was successful because it gives me a cow(cowsay), that tells me a fortune(fortune), that is very colorful(lolcat).

Conclusion

Starting out with the terminal can be intimidating at first but once you're familiar with it, it will become your best friend. It makes traversing through your file system faster and easier, and also downloading programs less of a pain because the script will take care of everything for you. Happy Scripting!

--

--