A little time ago, I found out, that I can create custom commandterminals with expanding the PATH-variable. Unfortunately, it gets always resettet, when I close the terminal and opens it again.
Do you know how to fix this problem?
Because when I want to start a few scripts with terminalcommands, I don't want to expand the PATH-variable everytime before …
Best Answer
I understand you have some executables in one of your home folders, e.g., in
~/bin
and you want to be able to execute them without always typing the full path~/bin/my_cool_executable
.You already observed that entering
PATH=~/bin:$PATH
in your terminal made things work... but only until you close the terminal. When you open a new one, your formerPATH
variable gets reset to its original value. By the way, I guess you know how to, at any time, check the value of thePATH
variable: like so:How to make your change permanent so that your
PATH
will still be the same when you reopen a new terminal? It's very easy, you just need to edit your.bashrc
file. Let's use thegedit
editor: In a terminal, type this:This opens up the
gedit
editor. Scroll to the end of the file and add this:and save the file and quit
gedit
. Then close your terminal and open a new one. Now yourPATH
variable should have~/bin
in front of it so that your commands in~/bin
will be accessible without typing their full path. And you know how to check that:echo "$PATH"
.Enjoy!
Warning. It is considered bad practice and a security vulnerability to put
.
in yourPATH
variable.