I'm trying to add a directory to my path so it will always be in my Linux path. I've tried:
export PATH=$PATH:/path/to/dir
This works, however each time I exit the terminal and start a new terminal instance, this path is lost, and I need to run the export command again.
How can I do it so this will be set permanently?
It can be directly added by using the following command:
echo 'export PATH=$PATH:/new/directory' >> ~/.zshrc source ~/.zshrc
You can use on Centos or RHEL for local user:
This add the current directory(or you can use other directory) to the PATH, this make it permanent but take effect at the next user logon.
If you don't want do a re-logon, then can use:
That reload the
# User specific environment and startup programs
this comment is present in.bash_profile
one way to add permanent path, which worked for me, is: cd /etc/profile.d touch custom.sh vi custom.sh export PATH=$PATH:/path according to your setting/ restart your computer and here we go path will there permanently cheers.