Let’s take a closer look at your home director. Make sure you are in your home directory by running
cd ~
If we list the contents in that directory we can see that there are plenty of interesting files around. For now we are going to focus on the following files that are used by the system. Notice that the usage of scripts in users’ home directories may differ between Linux distributions. We are focusing on the Ubuntu standard.
.bash_history
.bashrc
.profile
.bash_logout
.bashrc
is executed for non-login shells. This means shells that you start up after you have already logged into your Linux installation. Every time you start a new shell, the commands in this script are executed.
Let’s change the command prompt
Have a look at that command prompt. Looks a bit dull, doesn’t it? Let’s liven up things with some colors.
We will need to change the $PS1
variable which is set for each user in the .bashrc
script. This runs for every interactive shell and takes settings for the logged in user.
So let’s open the .bashrc
file. You can use vi or less for this purpose, but remember that when you want to edit the file you’ll need the vi tool.
Look for the $PS1
variable in the script. To search in the file, press the forward slash (/) and enter the search term, here PS1. Press Enter and vi will show you the first match. Do you see the pound sign in the first position on the matched line. This signifies a comment in Bash. Bash is the command interpreter and you can write scripts that contain several commands that are run in sequence. In such scripts it can be useful to have comments to simplify reading the script.
In the next lesson you will learn how to create empty files and make them executable as scripts. Head over to the final lesson “Creating files and making them executable“.