E-Mail:

CLI Magic: Customizing your bash environment

An environment is a collection of concepts that express the things a computer system does in terms designed to be understandable and coherent, and a look and feel that is comfortable. Unix shells present you with such concepts as files, directories, and standard input and output, while Unix itself gives you tools to work with these, such as file manipulation commands, text editors, and print queues. There are also more sophisticated ways of customizing your shell environment.

The .bash_profile, .bash_logout, and .bashrc files

Three files in your home directory have a special meaning to bash, providing a way for you to set up your account environment automatically when you log in and when you invoke another bash shell, and allowing you to perform commands when you log out. These files may already exist in your home directory, depending on how your system administrator has set up your account. If they don’t exist, your account is using only the default system file /etc/profile. You can easily create your own bash files using your favorite text editor.

The most important bash file, .bash_profile, is read and the commands in it executed by bash every time you log in to the system. If you examine your .bash_profile you will probably see lines similar to:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
SHELL=/bin/bash
MANPATH=/usr/man:/usr/X11/man
EDITOR=/usr/bin/vi

PS1=’\h:\w\$ ‘
PS2=’> ‘
export EDITOR

These lines define the basic environment for your login account. When editing your .bash_profile, just add your new lines after the existing ones.

Note that whatever you add to your .bash_profile won’t take effect until the file is re-read by logging out and then logging in again. Alternatively, you can also use the source command. For example:

source .bash_profile

Complete Article

What Do You Think?

 

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

64 queries / 1.716 seconds.