Setting envirnoment variable in linux

Hai Linux,

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

when installing some software, it has its own envirnoment variable, how to set it?

Thanks in advance.

+3
source share
3 answers

You add the path to the executable to the PATH environment variable. For example, if you assume the 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 this line to ~ / .bash_profile

+4
source

bash ( , , Linux), , , ~/.bash_profile, .

:

export PATH=$PATH:~/bin

mkdir ~/bin

, . Voila, , .

, bash , , awk, ls cp, ~/bin, . , , - , ( , , , ).

, , ( bash):

export name=value

name value. export, set, .

+4

bash :

export name=value
0

Source: https://habr.com/ru/post/1719945/


All Articles