This question has already been answered:

Hello, I recently began to master this OS. If in Windows it was clear where to write environment variables (for java, gradle and ant), then in Ubuntu I had difficulties. The anta documentation says that you need to use the export command, but then after the session ends, this variable flies. I understand that in order to set a variable in the env "for good" you need to specify it in a certain bash. But I didn’t really find a step-by-step instruction on the network (although I might have asked Google wrong) about which command to write in order to log in to bash and set the necessary variables. Please explain how to do this?

Reported as a duplicate by members aleksandr barakin , sercxjo , zRrr , VenZell , D-side 31 May '16 at 11:21 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

    ls ~ 

    There you will see either .bashrc or .bash_profile Open for change

     nano ~/.bashrc 

    At the end of the file enter the necessary, for example

     export DEMO_ENV=success 

    Press ctrl + x then y and enter after run

     source ~/.bashrc 

      There was an answer here

      1. open the file / etc / environment
      2. write the necessary variables:

        export VAR_NAME = VAR_VALUE

      • I saw that answer, and if it did, I would not ask this question again. So I open the terminal and write ~ / .bashrc, in response, he writes, "access denied" - Iga
      • file environment can some command in the console open? otherwise I found it by the method of the tractor driver; I found it in the folder etc, dragged it to the console with the mouse and pressed enter. opened a text document in which one line PATH = ..... - Iga
      • @lga open the file with admin rights. - bmsdave
      • I apologize, but I am absolutely noob (what team to do this? - Iga
      • one
        1 open the terminal. 2 enter "sudo nano / etc / enviroment" 3. enter the necessary environment variables. 4. Ctrl + O -> Enter Ctrl + X. 5 go again and check - bmsdave