Permanent PATH variable











up vote
20
down vote

favorite
10












How will I make this /media/De Soft/mongodb/bin PATH variable permanent?



Everyone is saying export PATH=$PATH:media/De Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your shell. I don't know what is ~/.profile, or .bashrc, or .zshenv. And what they do actually?



And how will I add export PATH=$PATH:my/path to my .profile/.bashrc/.zshenv? I'm using 64 bit Ununtu 14.04 LTS with default terminal. I'm very newbie to Linux.










share|improve this question




























    up vote
    20
    down vote

    favorite
    10












    How will I make this /media/De Soft/mongodb/bin PATH variable permanent?



    Everyone is saying export PATH=$PATH:media/De Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your shell. I don't know what is ~/.profile, or .bashrc, or .zshenv. And what they do actually?



    And how will I add export PATH=$PATH:my/path to my .profile/.bashrc/.zshenv? I'm using 64 bit Ununtu 14.04 LTS with default terminal. I'm very newbie to Linux.










    share|improve this question


























      up vote
      20
      down vote

      favorite
      10









      up vote
      20
      down vote

      favorite
      10






      10





      How will I make this /media/De Soft/mongodb/bin PATH variable permanent?



      Everyone is saying export PATH=$PATH:media/De Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your shell. I don't know what is ~/.profile, or .bashrc, or .zshenv. And what they do actually?



      And how will I add export PATH=$PATH:my/path to my .profile/.bashrc/.zshenv? I'm using 64 bit Ununtu 14.04 LTS with default terminal. I'm very newbie to Linux.










      share|improve this question















      How will I make this /media/De Soft/mongodb/bin PATH variable permanent?



      Everyone is saying export PATH=$PATH:media/De Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your shell. I don't know what is ~/.profile, or .bashrc, or .zshenv. And what they do actually?



      And how will I add export PATH=$PATH:my/path to my .profile/.bashrc/.zshenv? I'm using 64 bit Ununtu 14.04 LTS with default terminal. I'm very newbie to Linux.







      bash environment-variables bashrc .profile mongodb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 21 '14 at 20:07

























      asked Jul 21 '14 at 19:37









      Towhid

      8753810




      8753810






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          45
          down vote



          accepted










          They are configuration files. One way:




          • Open a terminal window using Ctrl+Alt+T

          • Run the command gedit ~/.profile


          • Add the line



            export PATH=$PATH:/media/De Soft/mongodb/bin



            to the bottom and save



          • Log out and log in again







          share|improve this answer























          • @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
            – yuranos87
            Mar 26 '17 at 21:12






          • 3




            @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:17










          • You don't need to logout and login again. Use source ~/.profile.
            – timbo
            Jul 11 '17 at 22:44






          • 1




            @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
            – Gunnar Hjalmarsson
            Jul 11 '17 at 23:44


















          up vote
          3
          down vote













          Type the following in a terminal window



          export PATH=/media/De Soft/mongodb/bin:$PATH 


          Close the terminal and restart the computer. The path should include /media/De Soft/mongodb/bin when you type this in the terminal:



          echo $PATH





          share|improve this answer

















          • 7




            That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
            – Alejandro Iván
            Aug 10 '16 at 16:38












          • agreed. but upon system restart it is loaded in the path variable.
            – Nivedita Velagaleti
            Aug 10 '16 at 19:43






          • 5




            @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:22


















          up vote
          0
          down vote













          To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:



          sudo cp /etc/environment /etc/environment.bak
          sudo nano /etc/environment


          sample output:



          PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


          Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:



          PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"





          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500775%2fpermanent-path-variable%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            45
            down vote



            accepted










            They are configuration files. One way:




            • Open a terminal window using Ctrl+Alt+T

            • Run the command gedit ~/.profile


            • Add the line



              export PATH=$PATH:/media/De Soft/mongodb/bin



              to the bottom and save



            • Log out and log in again







            share|improve this answer























            • @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
              – yuranos87
              Mar 26 '17 at 21:12






            • 3




              @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:17










            • You don't need to logout and login again. Use source ~/.profile.
              – timbo
              Jul 11 '17 at 22:44






            • 1




              @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
              – Gunnar Hjalmarsson
              Jul 11 '17 at 23:44















            up vote
            45
            down vote



            accepted










            They are configuration files. One way:




            • Open a terminal window using Ctrl+Alt+T

            • Run the command gedit ~/.profile


            • Add the line



              export PATH=$PATH:/media/De Soft/mongodb/bin



              to the bottom and save



            • Log out and log in again







            share|improve this answer























            • @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
              – yuranos87
              Mar 26 '17 at 21:12






            • 3




              @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:17










            • You don't need to logout and login again. Use source ~/.profile.
              – timbo
              Jul 11 '17 at 22:44






            • 1




              @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
              – Gunnar Hjalmarsson
              Jul 11 '17 at 23:44













            up vote
            45
            down vote



            accepted







            up vote
            45
            down vote



            accepted






            They are configuration files. One way:




            • Open a terminal window using Ctrl+Alt+T

            • Run the command gedit ~/.profile


            • Add the line



              export PATH=$PATH:/media/De Soft/mongodb/bin



              to the bottom and save



            • Log out and log in again







            share|improve this answer














            They are configuration files. One way:




            • Open a terminal window using Ctrl+Alt+T

            • Run the command gedit ~/.profile


            • Add the line



              export PATH=$PATH:/media/De Soft/mongodb/bin



              to the bottom and save



            • Log out and log in again








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 22 '14 at 14:55

























            answered Jul 21 '14 at 20:21









            Gunnar Hjalmarsson

            18.8k23161




            18.8k23161












            • @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
              – yuranos87
              Mar 26 '17 at 21:12






            • 3




              @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:17










            • You don't need to logout and login again. Use source ~/.profile.
              – timbo
              Jul 11 '17 at 22:44






            • 1




              @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
              – Gunnar Hjalmarsson
              Jul 11 '17 at 23:44


















            • @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
              – yuranos87
              Mar 26 '17 at 21:12






            • 3




              @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:17










            • You don't need to logout and login again. Use source ~/.profile.
              – timbo
              Jul 11 '17 at 22:44






            • 1




              @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
              – Gunnar Hjalmarsson
              Jul 11 '17 at 23:44
















            @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
            – yuranos87
            Mar 26 '17 at 21:12




            @GunnarHjalmarsson, do I really need to export PATH var? Maybe, it is done by default in some other script? I have checked by ~/.profile and a PATH var is there, but it is not explicitly exported: PATH=~/.local/bin:$JAVA_HOME/bin:$PATH
            – yuranos87
            Mar 26 '17 at 21:12




            3




            3




            @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:17




            @yuranos87: No, you are right; when modifying PATH in ~/.profile, exporting is redundant, since PATH already is an environment variable.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:17












            You don't need to logout and login again. Use source ~/.profile.
            – timbo
            Jul 11 '17 at 22:44




            You don't need to logout and login again. Use source ~/.profile.
            – timbo
            Jul 11 '17 at 22:44




            1




            1




            @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
            – Gunnar Hjalmarsson
            Jul 11 '17 at 23:44




            @timbo: That does not make the variable available to already started processes in the session (except for the current terminal).
            – Gunnar Hjalmarsson
            Jul 11 '17 at 23:44












            up vote
            3
            down vote













            Type the following in a terminal window



            export PATH=/media/De Soft/mongodb/bin:$PATH 


            Close the terminal and restart the computer. The path should include /media/De Soft/mongodb/bin when you type this in the terminal:



            echo $PATH





            share|improve this answer

















            • 7




              That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
              – Alejandro Iván
              Aug 10 '16 at 16:38












            • agreed. but upon system restart it is loaded in the path variable.
              – Nivedita Velagaleti
              Aug 10 '16 at 19:43






            • 5




              @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:22















            up vote
            3
            down vote













            Type the following in a terminal window



            export PATH=/media/De Soft/mongodb/bin:$PATH 


            Close the terminal and restart the computer. The path should include /media/De Soft/mongodb/bin when you type this in the terminal:



            echo $PATH





            share|improve this answer

















            • 7




              That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
              – Alejandro Iván
              Aug 10 '16 at 16:38












            • agreed. but upon system restart it is loaded in the path variable.
              – Nivedita Velagaleti
              Aug 10 '16 at 19:43






            • 5




              @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:22













            up vote
            3
            down vote










            up vote
            3
            down vote









            Type the following in a terminal window



            export PATH=/media/De Soft/mongodb/bin:$PATH 


            Close the terminal and restart the computer. The path should include /media/De Soft/mongodb/bin when you type this in the terminal:



            echo $PATH





            share|improve this answer












            Type the following in a terminal window



            export PATH=/media/De Soft/mongodb/bin:$PATH 


            Close the terminal and restart the computer. The path should include /media/De Soft/mongodb/bin when you type this in the terminal:



            echo $PATH






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 10 '16 at 16:35









            Nivedita Velagaleti

            951




            951








            • 7




              That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
              – Alejandro Iván
              Aug 10 '16 at 16:38












            • agreed. but upon system restart it is loaded in the path variable.
              – Nivedita Velagaleti
              Aug 10 '16 at 19:43






            • 5




              @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:22














            • 7




              That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
              – Alejandro Iván
              Aug 10 '16 at 16:38












            • agreed. but upon system restart it is loaded in the path variable.
              – Nivedita Velagaleti
              Aug 10 '16 at 19:43






            • 5




              @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
              – Gunnar Hjalmarsson
              Mar 26 '17 at 21:22








            7




            7




            That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
            – Alejandro Iván
            Aug 10 '16 at 16:38






            That only works for current terminal session. It needs to be in ~/.profile (or ~/.bashrc on common GNU/Linux distros... even ~/.bash_profile) to be run on every console load.
            – Alejandro Iván
            Aug 10 '16 at 16:38














            agreed. but upon system restart it is loaded in the path variable.
            – Nivedita Velagaleti
            Aug 10 '16 at 19:43




            agreed. but upon system restart it is loaded in the path variable.
            – Nivedita Velagaleti
            Aug 10 '16 at 19:43




            5




            5




            @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:22




            @NiveditaVelagaleti: No it's not unless you make it persistent via a config file. The terminal command does not modify PATH persistently.
            – Gunnar Hjalmarsson
            Mar 26 '17 at 21:22










            up vote
            0
            down vote













            To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:



            sudo cp /etc/environment /etc/environment.bak
            sudo nano /etc/environment


            sample output:



            PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


            Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:



            PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"





            share|improve this answer

























              up vote
              0
              down vote













              To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:



              sudo cp /etc/environment /etc/environment.bak
              sudo nano /etc/environment


              sample output:



              PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


              Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:



              PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:



                sudo cp /etc/environment /etc/environment.bak
                sudo nano /etc/environment


                sample output:



                PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


                Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:



                PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"





                share|improve this answer












                To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:



                sudo cp /etc/environment /etc/environment.bak
                sudo nano /etc/environment


                sample output:



                PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


                Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:



                PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 19 at 18:51









                Xaqron

                662611




                662611






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500775%2fpermanent-path-variable%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents