Is it possible to coerce bash to reload the .profile file without logging out and back in again?

up vote 85 down vote accepted

This should work for the current terminal:

. ~/.profile

. is a bash builtin and a synonym for source, see man bash:

. filename [arguments]
source filename [arguments]
     Read and execute commands from filename in the current shell environment (…).

  • 15
    It will be effective only in the current terminal. – enzotib Aug 29 '11 at 14:14
  • @enzotib Is there a way to work around that? – Matty Aug 29 '11 at 14:20
  • 10
    @Matty: no, to make the changes visible to the whole graphical environment, you can only restart the session – enzotib Aug 29 '11 at 14:22
  • 1
    The only issue with this is if you remove something from path it would not take effect until you restart – Aras Sep 12 '16 at 19:44
  • @enzotib Is it effective for all sub processes started from current terminal? – Bruce Sun Aug 4 '17 at 2:39

If you don't want to start a new shell but execute the script in the current shell, you source it:

source script_name.sh

source = .

The Bash source built-in is a synonym for the Bourne shell . (dot) command.

courtesy - tldp.org

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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