Performing actions like changing your PS1 shell prompt can be quite fun. And adding personal extras to the contents of PATH can be very useful. However, when you have to perform these actions every time you login before they will take effect, it can soon become quite tedious.
The solution to this problem is to create a personal login script which the shell will automatically read and execute for you when you login. A personal login script is effectively just a shell script that gets executed at login time. If you have a personal login script, it must be stored in your home directory. When you login, bash will look in your home directory for one of three specific file names. These are:
~/.bash.profile ~/. bash_login ~/.profile
bash looks for the three file names in this order and just executes the first one of them that it finds.
When you logout, bash can also execute a personal logout script. Again, this must be stored in your home directory and under the name:
~/bash_logout
In addition to the personal scripts that bash can execute, it is also possible for the system administrator to create a global login script called:
/etc/profile
which bash will execute for every user as they login. This allows the system administrator to set up local configurations for the system as a whole. If it exists, the global login script will be executed before your personal script so that your personal script can customize your environment even further. For example, something which often appears in this global file is the line which sets the shell to ignore end-of-file (Ctrl-d) for logging out. If the file contains a line with the word ignoreeof then removing the line will allow you to log out with Ctrl-d.
The next example shows how easy it is to set up a personal login script to customize your shell prompt and add your own bin directory to the list in PATH:
$ cat >~/.profile PS1='What Now! ' PATH=~/bin:$PATH Ctrl-d