update - source/.bash_profile not working




How to reload.bash_profile from the command line? (10)

  1. Save .bash_profile file
  2. Goto user's home directory by typing cd
  3. Reload the profile with . .bash_profile

How can I reload .bash_profile from the command line? I can get the shell to recognize changes to .bash_profile by exiting and logging back in but I would like to be able to do it on demand.


Add alias bashs="source ~/.bash_profile" in to your bash file. So you can call bashs from next time


I like the fact that after you have just edited the file, all you need to do is type:

. !$

This sources the file you had just edited in history. See What is bang dollar in bash.


I use Debian and I can simply type exec bash to achieve this. I can't say if it will work on all other distributions.


If you don't mind losing the history of your current shell terminal you could also do

bash -l

That would fork your shell and open up another child process of bash. The -l parameter tells bash to run as a login shell, this is required because .bash_profile will not run as a non-login shell, for more info about this read here

If you want to completely replace the current shell you can also do:

exec bash -l

The above will not fork your current shell but replace it completely, so when you type exit it will completely terminate, rather than dropping you to the previous shell.


Simply type source ~/.bash_profile

Alternatively, if you like saving keystrokes you can type . ~/.bash_profile


You can also use this command to reload the ~/.bash_profile for that user. Make sure to use the dash.

su - username

if the .bash_profile does not exist you can try run the following command:

. ~/.bashrc 

or

 source ~/.bashrc

instead of .bash_profile. You can find more information about bashrc


. ~/.bash_profile

Just make sure you don't have any dependencies on the current state in there.


alias reload!=". ~/.bash_profile"

or if wanna add logs via functions

function reload! () {
    echo "Reloading bash profile...!"
    source ~/.bash_profile
    echo "Reloaded!!!"
}




.bash-profile