FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

Configuring the bash shell


Bash Configuration files:

  1. You can setup files that automatically configure your working environment every time you login. The three major configuration files for the bash shell are:
    1. /etc/profile - generic system-wide profile
    2. .bash_profile - personal profile that is processed every time you login
    3. .bashrc - setup file processed every time you open a non-login shell

Modifying the prompt:

  1. In a command interface, the prompt is what you see on the screen when the system is waiting for you to enter your next command.
  2. Under the bash shell, the primary prompt is stored in a variable called PS1.
  3. To change the prompt you use the command: PS1='value'
    eg:  PS1='type something!  '
  4. Some of the codes that can go in the prompt are:


  1. An alias lets you setup typing shortcuts. An example of an alias would be:
     alias byebye='logout'
    When you type byebye, bash will interpret this as logout.
  2. To cancel the alias, use the command:
    unalias byebye
  3. To view any aliases that are already defined for your account, use the command: alias

Bash Shell Options:

  1. There are a number of options that can be set; one of the most useful is the noclobber option. If noclobber is on, then you cannot accidentally overwrite a file using redirection.
  2. The command to turn on the noclobber option is: set -o noclobber
  3. The command to turn off the noclobber option is:


  1. Answer the following questions about the current setup:
    1. What is stored in the current .bash_profile?
    2. What is your prompt?
    3. What is your path?
    4. What is your umask value?
    5. Are there any aliases set up?
  2. Change the prompt as follows:
    1. Change the prompt to -->
    2. Change the prompt to 2 lines:
         Get going
         Enter your next command>
    3. Change the prompt to: your working directory followed by a $
    4. When you change directories, does the prompt change to the new directory name? (it will if you've set it correctly)
    5. Logout and login again. Was the new prompt saved or has it gone back to $ ?
  3. Setup aliases as follows:
    1. Setup dir as an alias for ls -l . Type dir. Did you get a long directory listing? __
    2. Is "rename" a valid command in floppix? _____
      Make rename an alias for mv. Now you should be able to use the command:
      rename readme ignoreme
      This should change the name of the readme file. Did it work?
    3. Does the rm command ask for confirmation before a file is deleted? Test it out.
      • copy the passwd file to mypass: cp /etc/passwd mypass
      • remove the passwd file: rm mypass
      • did you receive a confirmation request before mypass was deleted? ___
    4. Create the following alias: rm='rm -i'
    5. Test your alias:
      • copy the passwd file to mypass: cp /etc/passwd mypass
      • remove the passwd file: rm mypass
      • did you receive a confirmation request before mypass was deleted?
  4. Test the noclobber option
    1. Turn on the noclobber option.
    2. Create the file flist using the command: ls -l > flist
    3. Repeat: ls -l > flist
    4. Did you get an error message?
    5. Turn off the noclobber option.
    6. Enter the command:  ls -l /etc > flist
    7. This time the command should overwrite flist with a newer version. Did it?
    8. Point to remember:
      -o turns noclobber ON
      +o turns noclobber OFF
  5. Create a .bash_profile that:
    1. sets the background color of the screen to black.
    2. sets the prompt to the name of the working directory followed by $ .
    3. sets the search path to /usr/bin and /bin .
    4. sets dir as an alias for ls -l .
    5. configures rm to prompt for confirmation before deleting a file.
    6. prevents bash from overwriting an existing file when redirecting output
    7. Test your profile - logout and login again.

Copyright © L.M.MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next