PATH environment variable

PATH is an environment variable.
When I open a terminal say terminal 1 and set some path in PATH variable it gets set which I can see using ech $PATH.

But when I open a new terminal say terminal 2 and fire echo $PATH why cannot I see the same output as seen in terminal terminal 1?
Why the path added to PATH variable using one terminal is not reflected in another terminal?

Because you have set it only for the active shell. If you'd export ed it, you would have it in every subshell started from the current one.
To have it in other sessions, you will have to edit your environment files like ~/.profile or your shell specific file like ~/.kshrc or ~/.bashrc and also source them or relogin.
If you have an already existing PATH set somewhere and want to add something, use

export PATH=$PATH:/my/new/path/entry

so that the existing path will not be overwritten but expanded by the new entry.

1 Like

I use export command only to add in path variables.Eg.:

export PATH=/my/new/path/entry/:$PATH

but still when I open a new sub shell the path is not present in the new shell.

Please start using code tags! Check the link in your previous post in the moderator comment for a guide!

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/games
$ export PATH=$PATH:/tmp
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/games:/tmp
$ env| grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/games:/tmp

Now starting a new subshell:

$ ksh
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/games:/tmp

I will take care of code tags.