Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

up vote 4 down vote accepted

You can put things like:

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


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

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
2  
+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

 
discard

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.