2

So I need to reload my profile after making changes (this time due to a typo). I run source ~/.profile and everything works perfectly fine.

However the source command only applies to that terminal session. This means I'm running the command every time I open up a new terminal. I want to find a way to apply the .profile/environmental variables to the entire user session without logging out, not just the current terminal.

Is there a package or command that can execute this type of change by reloading the profile like it loaded on login?

EDIT: To clarify that it is not a duplicate I don't want to use:

source ~/.profile

or

. ~/.profile

As they only effect changes on one terminal session. I want to effect changes across all started terminals from my user session. I already have changes in the current terminal session using those commands. I need them in newly opened terminal after I run the command (which to clarify I don't currently have. the changes are only effecting the current terminal and my question is to effect these changes across multiple terminals

  • 1
    This will depend on your display manager, but this answer has an explanation of why it isn't possible usually, and specifically for the default Ubuntu display manager: https://unix.stackexchange.com/questions/2949/how-do-i-tell-gnome-to-reread-my-profile – Tgr Jan 07 '23 at 03:03

1 Answers1

2

You cannot. Environment variables are kept in each shell's per-process memory. Other processes (other shells, like the one you want to change eveything) cannot access this memory. Nor does bash listen to a socket for getting updates.

Reread man bash, especially the INVOCATION section.

~/.profile is more a ksh startup file. However, you could put source $HOME/.profile in your ~/.bashrc.

waltinator
  • 36,399