How to permanently set $PATH on Linux/Unix
Ғылым және технология
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
Пікірлер: 16
thank you for your usefull video, i have one question, is it possible to create a shell and and it set the path automaticlly in the bashrc after you run your bash for once?
I can't find .bashrc under ls -al command. Basically the problem I'm facing is I'm not able to use sudo commands outside of its own file which is annoying.
@RabiGurungXybernetics
6 ай бұрын
Sounds like you need to use chown command to the folder. Let me know if you need more help about chow command.
you saved my day, thank you
@RabiGurungXybernetics
Жыл бұрын
I am happy it worked for you. Thanks for leaving a comment.
Thanks, this is easy and so useful
@RabiGurungXybernetics
Жыл бұрын
You're welcome!
How did you save it after typing the PATH command?
@RabiGurungXybernetics
Жыл бұрын
I am using Nano (a text editor for Linux) in the video and I am using Ctrl+X to save and exit. If you want to just save and continue using nano, press Ctrl + O. Just for the benefit of all other text editor user users, I have compiled how to save and save & edit keys combinations. 🎉Vim Users If you are using Vim, to save a file it is / vi, press Esc key, type :w and hit Enter key. If you want to save a file and quit the text editor, it is / vi by pressing Esc key, type :x and hit Enter key 🚀Vi Users If you are using Vi, to save a file press Esc on your keyboard to enter Command mode, and then type :w. If you want to save a file and quit the text editor, press Esc key to enter Command mode, and then type :wq. 👑Emacs Users If you are using Emacs, to save a file press Ctrl + x Ctrl + s. If you want to save a file and quit the text editor, press Ctrl + x Ctrl + c.
thanks man
@RabiGurungXybernetics
Жыл бұрын
No problem!
thank you
@RabiGurungXybernetics
Жыл бұрын
You're welcome
Thanks
@RabiGurungXybernetics
8 ай бұрын
Welcome