Cover by Cameron Newham, JP Vossen, Carl Albing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Getting Started with a Custom Configuration

Problem

You'd like to tweak your environment but aren't quite sure where to start.

Solution

Here are some samples to give you an idea of what you can do. We follow the suggestion in Creating Self-Contained, Portable RC Files, "Creating Self-Contained, Portable RC Files" to keep customizations separate for easy back-outs and portability between systems.

For system-wide profile settings, add the following to /etc/profile. Since that file is also used by the true Bourne shell, be careful not to use any bash-only features (e.g., source instead of .) if you do this on a non-Linux system. Linux uses bash as the default shell for both /bin/sh and /bin/bash (except when it doesn't, as in Ubuntu 6– 10+, which uses dash). For user-only settings, add it to only one of ~/.bash_profile, ~/.bash_login, or ~/.profile, in that order, whichever exists first:

	# cookbook filename: add_to_bash_profile

	# If we're running in bash, search for then source our settings
	# You can also just hard code $SETTINGS, but this is more flexible
	if [ -n "$BASH_VERSION" ]; then
	    for path in /opt/bin /etc ~ ; do 
	        # Use the first one found 
	        if [ -d "$path/settings" -a -r "$path/settings" -a -x "$path/settings" ] 
	        thenexport SETTINGS="$path/settings"
	        fi
	    done
	    source "$SETTINGS/bash_profile"
	    #source "$SETTINGS/bash_rc"      # If necessary
	fi

For system-wide environment settings, add the following to /etc/bashrc (or /etc/bash. bashrc):

 # cookbook filename: add_to_bashrc # If we're running in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required