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?


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

| improve this answer | |
  • let me try that... so why executing .bashrc doesn't work? – Radek Aug 12 '10 at 1:46
  • 2
    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


source ~/.bashrc

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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