Click Upvote Click Upvote - 7 months ago 25
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?


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