Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I frequently edited the .bashrc file to export new environment variables.

Rather than close the console and start a new one to refresh the env variables, is there a convenient way to refresh?

share|improve this question
up vote 39 down vote accepted

Within the same window, you can simply type bash to start a new one. This is equivalent to closing the window and re-opening a new one.

Alternatively, you can type source ~/.bashrc to source the .bashrc file.

share|improve this answer
No need to execute another shell. source is the correct way – Matteo Dec 13 '11 at 6:18
also there is no need to type long word source. you can just type dot instead of it: . ~/.bashrc. – rush Dec 13 '11 at 6:31
@Rush typing source shows the user which command is called. I don't believe in showing the shorthanded commands to new users until they understand what the code is doing. – n0pe Dec 13 '11 at 6:34
note that merely sourcing bashrc is not necessarily equal to a restart of bash. defined variables are not automatically undefined. shell options are not automatically unset. sourcing bashrc only executes what is written in bashrc. it does not rollback any other changes in the environment. starting a new bash session inside the old is also not necessarily equal to a restart of bash, as the new process inherits the environment from the old. – lesmana Dec 13 '11 at 20:57
@MaxMackie Considering how source is a bashism that is longer to type yet offers no advantages over its portable across all shells equivalent, ., I don't see the point of encouraging anyone, new or experienced, to use it. – jw013 Dec 15 '11 at 2:27

Just use

source ~/.bashrc


. ~/.bashrc
share|improve this answer

I am using an installer which is adding entry of environment variable in bash_profile file, when i am starting jetty server, it was unable to find that entry..when i run source ~/.bash_profile it rerlaods the bash profle and server starts succesfully without any issues..The problem is customer is not going to start a new session nor he is going to manually refresh the bash_profile.I tried to add the "source ~/.bash_profile" command inside a shell script and i called that shell script when i invoke the startup file of jetty server but it also doesn't work..Is there any other way we can reload the bash profile of current session?Any information you can provide me would be greatly appreciated.

share|improve this answer

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.