Click Upvote Click Upvote - 1 year ago 134
Linux Question

How to permanently set $PATH on Linux?

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?

Answer Source

You need to add it to your ~/.profile file.

export PATH=$PATH:/path/to/dir

Depending on what you're doing, you also may want to symlink to binaries:

cd /usr/bin
sudo ln -s /path/to/binary binary-name
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download