Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I have different .bashrc files loading when logging into different nodes that share the same home dir?

This is, I am mostly interested to loading different PATH directories when logging as bash, depending on the different Linux nodes I log into? For example, if I log into bash in machine abc-01, I would like to have a given .bashrc loaded, but when I log into abc-02, that uses the same /home/username directory, I would like to use a different .bashrc. How can I go about doing that?

share|improve this question
up vote 7 down vote accepted

You can put things like:

if [ $HOSTNAME = "abc-01" ]; then
        sh ~/.bashrc_abc01

if [ $HOSTNAME = "abc-02" ]; then
         sh ~/.bashrc_abc02

in .bashrc and create different scripts .bashrc_abc01, .bashrc_abc02 with the actual commands. Or if there are not that many commands, you can put them in the if statements.

share|improve this answer
+1 or do something like . ./.bashrc-$(hostname) – glenn jackman Apr 14 '12 at 14:00
yes, that's shorter – lupincho Apr 14 '12 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.