How to permanently set $PATH on Linux/Unix

preview_player
Показать описание
Learn how to permanently set $PATH on Linux/Unix.

You can set the PATH environment variable, using the following command.

export PATH=$PATH:/path/to/my/binary/file/

However, each time you exit the terminal or SSH session, and start a new terminal session, this PATH is lost. You have to run the same command again to recover the path. How can you permanently set this path?

Here are the step on how to resolve it.
1) cd ~
2) sudo nano .bashrc
3) Add the following line at the very bottom of file .bashrc.
export PATH=$PATH:/usr/local/go/bin
4) Save the .bashrc and exit.
5) ctrl + D to exit the terminal
6) Log back again.

#linux #ubuntu #path
Рекомендации по теме
Комментарии
Автор

Seriously This is the best explanation on Planet Earth . I am cursing myself why I would not come across this video long back.Thank ou Rabi. you showed me the light to the PATH 🙂

anilkommalapati
Автор

this was the clearest explanation of adding a bin to the path variable. thank you, worked like a charm.

hemanthkumarar
Автор

It worked thanks but do I need to edit .bashrc everytime I install new package? 💀

QuantumCanvas
Автор

extra tip echo $0 tells if it's bashrc or zshrc your terminal used

larvitaryang
Автор

Maybe I am just too noobie but it still isn't working

patrickmarchand