~/ sweet $HOME





This will be written piece by piece, slowly, so please consider it work in progress

I mostly use slackware. If you use something else that's up to you, most of these should work for you anyway.




~/ means the same as $HOME, it's a "shortcut" to your homedirectory.

~username refers to that user's homedirectory, by default you are username hence ~ is you and / is the "root" of your homedirectory.


Let's take a look at the files in question :-)

From the bash "man" file:

/bin/bash
The bash executable

/etc/profile
The systemwide initialization file, executed for login shells

~/.bash_profile
The personal initialization file, executed for login shells

~/.bashrc
The individual per-interactive-shell startup file

~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits

~/.inputrc
Individual readline initialization file

/bin/bash is pretty uninteresting, aside from the path which can be handy to remember if you are going to shellscript. It's just where the program file that is your shell resides.

/etc/profile is important though. notice the "systemwide initialization file" part? This is the file that sets up your basic settings. This is a file you want to look through at least if not read properly and examine.

It's also a file you as a user usually can't do much about, thus enter:

~/.bash_profile, this one is very important, it's pretty much the heart of your setup. Changes here affect your working environment.

and

~/.bashrc This one also affects your working environment, in some distributions(redhat) it is included in the beginning of ~/bash_profile like below

# check if ~/.bashrc exists, if it does, read it
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
bashrc is for "non login interactive shells" (long offsite explanation here) basically this means that it is not read when you login(unless you use the include trick above), but it IS read for each shell started (for instance if you run a shell script).

so basically the files we'll be working with most are .bashrc and .bash_profile as well as .bash_logout


One thing to keep in mind is that .bashrc and .bash_profile (as well as /etc/profile) are all in reality shell scripts.

This is good cause it means you can define functions (consider a function a subroutine or a block of multiple commands to be executed by typing a single command)


one thing that is almost always a problem is the "oops factor" as in "oops i copied a file over..." or "oops i moved a file to the wrong location and overwrote" or "oops i removed the wrong file..."

these three put into your .bash_profile will save you that

# Aliases to avoid Oopsies, add interactive check to them
alias cp="cp -i"
alias mv="cp -i"
alias rm="cp -i"


you may also like me do quite a bit of shell scripting or perl scripting, and thus want those scripts easily accessable. make a ~/bin and put your files there then use:

#add my extra directory "bin" to the path
export PATH=$PATH:~/bin

to add it to your path, depending on if you call scripts from your scripts you may want to put this one in your .bashrc (or like above, just include the bashrc in the top of your .bash_profile .




w0nderer