What is a Bash profile and how to edit one's profile to do useful stuff

Typically we interact with the Linux operating system through what is referred to as a shell interpreter. A common interpreter is the Bourne Again Shell, which people call by the catchy name of bash (you will also come across zsh and others). Think of the relationship of the Shell and Linux like that between your steering wheel and your car. The steering wheel is not the car, just as bash is not Linux. Rather the steering wheel lets you interact with your car in ways that make the car useful, just like typing commands into the Shell lets us make Linux do our bidding.

When one opens up a new Terminal window, we are presented with a prompt for typing commands that will be interpreted by the shell. We can configure and customize the shell by specifying settings in a text file. For bash one of the configuration files that you can modify is ~/.bash_profile. This is a text file that includes Bash variables commands (the ~/ indicates that it is located in one’s home directory). Bash commands are simply those commands that one can type into the Bash Shell (all the stuff we normally use is fair game, like ls or cd, but there are ways to make the program more useful than printing the contents of one’s home directory to STDOUT, see below).

Note the period that starts the file name (“.bash_profile”). This means the file is typically not listed with ls or visible in the file browser. To see all files, including those that start with ., use ls -a. These invisible files typically hold info that lets one customize some aspect of the computing experience.

If you don’t have a bash profile in your home directory, don’t worry. Simply make and edit one using an editor such as nano: nano ~/.bash_profile Once you have written your spiffy new Bash profile you either need to open up a new Shell or source the settings. To do the latter, type source ~/.bash_profile

Useful configurations

Ok, so what useful things can we put in a Bash profile? The answer is anything one can think of that makes doing computing easier. Here are a few simple examples:

Lots and lots of recipes exist for putting useful things in a Bash profile. Do some googling and then get creative. You will likely find lots of convenient ways to improve your computing experience through modification of the Bash profile.

Note that if you edit your profile in Nano to save and exit the program see the instructions at the bottom of the editing window.