When set a directory as persistent, export should be employed and add it to ~/.bashrc

export PATH

Does this mean that my current working shell is a subshell created from a parent-shell in script ~/.bashrc

$ var=3; export var; bash
$ echo $var

The parent shell export the variable to subshell.

Does ~/.bashrc work this way?

2 Answers 2


No, ~/.bashrc does not start a new shell.

The ~/.bashrc initialization file is sourced, i.e. read and executed in the same environment as the shell that invoked it (not run as a script).

The shell is essentially doing source ~/.bashrc or . ~/.bashrc to execute the contents of the file without spawning a new shell instance.

When you do export variable=value on the command line (or variable=value; export variable), you set variable to value and you mark the variable as "exported", i.e. it is turned into an environment variable that will be inherited by subsequent processes started from the same shell. No new shell is started by export.


There's no point in spawning a new shell and .bashrc is not a script, rather a text file. You can see what's going on when you monitor your shell's PID and introduce changes to your .bashrc. For them to take effect, just source the file:

. ~/.bashrc

No new process is spawned. It's as if you typed by hand all those lines included in that file. export by itself doesn't require a new shell. It only changes the environment, which can be inherited in the future.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .