Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting envirnoment variable in linux

Tags:

linux

Hai Linux,

I wrote a small c program using gcc compiler and i named the executable has hello i want this hello to be executed from any place . How to set the environment variable in bash shell?.

while installing some software it has it's own envirnoment variable how to set that?.

Thank you in advance.


1 Answers

You add the path to the executable to the PATH environment variable. For example, assuming a bash shell, and the path to the program /home/username/program/hello, you do the following:

export PATH=$PATH:/home/username/program

If you want this to be set automatically, add that line to ~/.bash_profile

like image 62
MichaelM Avatar answered Aug 08 '26 10:08

MichaelM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!