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.

I added new alias into .bashrc

Running .bashrc doesn't create that alias but new log in yes.

Could you somebody explain why is that so and how I can test if the new .bashrc works without doing test log in?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

"exec bash" should do it. Basically just restarts the bash shell, reading .bashrc in the process.

share|improve this answer
    
let me try that... so why executing .bashrc doesn't work? –  Radek Aug 12 '10 at 1:46
    
works nicely. Thank you –  Radek Aug 12 '10 at 1:48
1  
When you execute ".bashrc" by itself it starts a new bash shell up (reading your new aliases) but keeps the old one active. Then it "does nothing" since you didn't ask it to do anything, and exits back to the old shell, restoring all your old aliases. –  hotei Aug 12 '10 at 1:53
3  
When you "exec bash" it REPLACES your old shell with the new one. "man exec" for all the details of how this works. It's also useful if your root account runs sh but you like bash better for some things (cwd in prompt in my case). You can make root run bash by "exec bash" as root. –  hotei Aug 12 '10 at 1:56
    
very nice explanation ... –  Radek Aug 12 '10 at 4:42

You can source the file using . or source:

. ~/.bashrc

or

source ~/.bashrc

That will re-read and execute the lines in the file in the current session.

share|improve this answer
    
works nicely.... –  Radek Aug 12 '10 at 4:59

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.