Friday, July 14, 2006

bashrc vs bash_profile

I was looking for a place to put my aliases and some suggested ~/.bashrc, others suggested ~/.bash_profile. By the way, my aliases are in ~/.bashrc and they are as follows:

# My Personal Alias
alias ipin='mount /mnt/ipod'
alias ipout='umount /mnt/ipod'
alias ipej='eject /mnt/ipod'

Anyway, 'man bash' turned up a mouthful of words which have been nicely summarised by someone from linuxquestions.org:

In other words, /etc/profile is run when a user logs in. ~/.bashrc is run for other shells (Ie opening an xterm)

/etc/profile contains environment variables and startup programs. Environ. var. are persistent - only need to read once. Startup programs are launched once - no need to start them again.

/etc/bashrc is included by ~/.bashrc, and read every time a shell starts up, people use it to include shell aliases and functions. Aliases and functions do not behave like environment variables; they are not passed to other processes.

There - that's why I put my aliases into bashrc ... I think ...

No comments: