Completely restart Bash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
16
down vote

favorite
8












Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.










share|improve this question



























    up vote
    16
    down vote

    favorite
    8












    Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.










    share|improve this question

























      up vote
      16
      down vote

      favorite
      8









      up vote
      16
      down vote

      favorite
      8






      8





      Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.










      share|improve this question















      Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.







      bash bashrc source bash-profile






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 11 at 7:38









      shgnInc

      31229




      31229










      asked Oct 16 '11 at 22:02









      Naftuli Kay

      11.6k53154247




      11.6k53154247




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          30
          down vote



          accepted










          Have it replace itself with itself.



          exec bash -l


          Note that this won't affect things such as the cwd or exported variables.






          share|improve this answer




















          • Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
            – Naftuli Kay
            Oct 16 '11 at 22:35






          • 1




            Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
            – Arcege
            Oct 17 '11 at 0:20










          • @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:23










          • So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
            – Naftuli Kay
            Oct 17 '11 at 3:35










          • As long as you're setting $PS1 in bash's startup files, yes.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:40

















          up vote
          9
          down vote













          I urgently suggest to log in on a separate window/screen. This way you still have a working session if something goes wrong with your changes to startup files. Also you are sure to have a clean environment.



          Reason: I saw too many people locking themselves out of a system because of a simple typo in their .profile (or such).






          share|improve this answer




















          • +10, a clean shell where you can change edits is essential.
            – Sardathrion
            Oct 17 '11 at 13:17










          • I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
            – Naftuli Kay
            Oct 17 '11 at 17:12

















          up vote
          3
          down vote













          If your goal is simply to read the modified files again, you don't have to restart it. You can simply source it.



          source filename


          or



          . filename # notice the dot


          Note that this won't give you a "clean state" in a sense that it won't unset any set variables or defined functions...






          share|improve this answer



























            up vote
            2
            down vote













            su -l yourOwnUserName


            Will open a fresh shell for yourOwnUserName user with all the settings re-loaded. This is shell-independent, as it refers to system settings, not your specific shell. It also loads some system-wide settings that bash -l does not (like user groups).






            share|improve this answer






















            • important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
              – underscore_d
              Sep 24 '15 at 0:40










            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f22721%2fcompletely-restart-bash%23new-answer', 'question_page');

            );

            Post as a guest






























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            30
            down vote



            accepted










            Have it replace itself with itself.



            exec bash -l


            Note that this won't affect things such as the cwd or exported variables.






            share|improve this answer




















            • Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
              – Naftuli Kay
              Oct 16 '11 at 22:35






            • 1




              Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
              – Arcege
              Oct 17 '11 at 0:20










            • @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:23










            • So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
              – Naftuli Kay
              Oct 17 '11 at 3:35










            • As long as you're setting $PS1 in bash's startup files, yes.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:40














            up vote
            30
            down vote



            accepted










            Have it replace itself with itself.



            exec bash -l


            Note that this won't affect things such as the cwd or exported variables.






            share|improve this answer




















            • Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
              – Naftuli Kay
              Oct 16 '11 at 22:35






            • 1




              Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
              – Arcege
              Oct 17 '11 at 0:20










            • @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:23










            • So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
              – Naftuli Kay
              Oct 17 '11 at 3:35










            • As long as you're setting $PS1 in bash's startup files, yes.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:40












            up vote
            30
            down vote



            accepted







            up vote
            30
            down vote



            accepted






            Have it replace itself with itself.



            exec bash -l


            Note that this won't affect things such as the cwd or exported variables.






            share|improve this answer












            Have it replace itself with itself.



            exec bash -l


            Note that this won't affect things such as the cwd or exported variables.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 16 '11 at 22:09









            Ignacio Vazquez-Abrams

            32.3k66780




            32.3k66780











            • Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
              – Naftuli Kay
              Oct 16 '11 at 22:35






            • 1




              Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
              – Arcege
              Oct 17 '11 at 0:20










            • @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:23










            • So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
              – Naftuli Kay
              Oct 17 '11 at 3:35










            • As long as you're setting $PS1 in bash's startup files, yes.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:40
















            • Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
              – Naftuli Kay
              Oct 16 '11 at 22:35






            • 1




              Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
              – Arcege
              Oct 17 '11 at 0:20










            • @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:23










            • So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
              – Naftuli Kay
              Oct 17 '11 at 3:35










            • As long as you're setting $PS1 in bash's startup files, yes.
              – Ignacio Vazquez-Abrams
              Oct 17 '11 at 3:40















            Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
            – Naftuli Kay
            Oct 16 '11 at 22:35




            Nice, but I'd especially like to do this in order to check and see if my PATH is being set as I want or my PS1, etc.
            – Naftuli Kay
            Oct 16 '11 at 22:35




            1




            1




            Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
            – Arcege
            Oct 17 '11 at 0:20




            Take out the exec and you get a shell that sources the files that you want. Then just exit when you are done checking.
            – Arcege
            Oct 17 '11 at 0:20












            @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:23




            @TK: Any variables you assign will take precedence over the ones left over from the previous shell.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:23












            So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
            – Naftuli Kay
            Oct 17 '11 at 3:35




            So this will work for changing my Bash prompt? Ie, it'll reload my bash prompt each time I run it?
            – Naftuli Kay
            Oct 17 '11 at 3:35












            As long as you're setting $PS1 in bash's startup files, yes.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:40




            As long as you're setting $PS1 in bash's startup files, yes.
            – Ignacio Vazquez-Abrams
            Oct 17 '11 at 3:40












            up vote
            9
            down vote













            I urgently suggest to log in on a separate window/screen. This way you still have a working session if something goes wrong with your changes to startup files. Also you are sure to have a clean environment.



            Reason: I saw too many people locking themselves out of a system because of a simple typo in their .profile (or such).






            share|improve this answer




















            • +10, a clean shell where you can change edits is essential.
              – Sardathrion
              Oct 17 '11 at 13:17










            • I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
              – Naftuli Kay
              Oct 17 '11 at 17:12














            up vote
            9
            down vote













            I urgently suggest to log in on a separate window/screen. This way you still have a working session if something goes wrong with your changes to startup files. Also you are sure to have a clean environment.



            Reason: I saw too many people locking themselves out of a system because of a simple typo in their .profile (or such).






            share|improve this answer




















            • +10, a clean shell where you can change edits is essential.
              – Sardathrion
              Oct 17 '11 at 13:17










            • I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
              – Naftuli Kay
              Oct 17 '11 at 17:12












            up vote
            9
            down vote










            up vote
            9
            down vote









            I urgently suggest to log in on a separate window/screen. This way you still have a working session if something goes wrong with your changes to startup files. Also you are sure to have a clean environment.



            Reason: I saw too many people locking themselves out of a system because of a simple typo in their .profile (or such).






            share|improve this answer












            I urgently suggest to log in on a separate window/screen. This way you still have a working session if something goes wrong with your changes to startup files. Also you are sure to have a clean environment.



            Reason: I saw too many people locking themselves out of a system because of a simple typo in their .profile (or such).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 17 '11 at 9:07









            ktf

            2,1261014




            2,1261014











            • +10, a clean shell where you can change edits is essential.
              – Sardathrion
              Oct 17 '11 at 13:17










            • I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
              – Naftuli Kay
              Oct 17 '11 at 17:12
















            • +10, a clean shell where you can change edits is essential.
              – Sardathrion
              Oct 17 '11 at 13:17










            • I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
              – Naftuli Kay
              Oct 17 '11 at 17:12















            +10, a clean shell where you can change edits is essential.
            – Sardathrion
            Oct 17 '11 at 13:17




            +10, a clean shell where you can change edits is essential.
            – Sardathrion
            Oct 17 '11 at 13:17












            I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
            – Naftuli Kay
            Oct 17 '11 at 17:12




            I'm in a DE, so it shouldn't be so bad, Bauhaus yes, be careful.
            – Naftuli Kay
            Oct 17 '11 at 17:12










            up vote
            3
            down vote













            If your goal is simply to read the modified files again, you don't have to restart it. You can simply source it.



            source filename


            or



            . filename # notice the dot


            Note that this won't give you a "clean state" in a sense that it won't unset any set variables or defined functions...






            share|improve this answer
























              up vote
              3
              down vote













              If your goal is simply to read the modified files again, you don't have to restart it. You can simply source it.



              source filename


              or



              . filename # notice the dot


              Note that this won't give you a "clean state" in a sense that it won't unset any set variables or defined functions...






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                If your goal is simply to read the modified files again, you don't have to restart it. You can simply source it.



                source filename


                or



                . filename # notice the dot


                Note that this won't give you a "clean state" in a sense that it won't unset any set variables or defined functions...






                share|improve this answer












                If your goal is simply to read the modified files again, you don't have to restart it. You can simply source it.



                source filename


                or



                . filename # notice the dot


                Note that this won't give you a "clean state" in a sense that it won't unset any set variables or defined functions...







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 16 '11 at 22:26









                rahmu

                9,9871868109




                9,9871868109




















                    up vote
                    2
                    down vote













                    su -l yourOwnUserName


                    Will open a fresh shell for yourOwnUserName user with all the settings re-loaded. This is shell-independent, as it refers to system settings, not your specific shell. It also loads some system-wide settings that bash -l does not (like user groups).






                    share|improve this answer






















                    • important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                      – underscore_d
                      Sep 24 '15 at 0:40














                    up vote
                    2
                    down vote













                    su -l yourOwnUserName


                    Will open a fresh shell for yourOwnUserName user with all the settings re-loaded. This is shell-independent, as it refers to system settings, not your specific shell. It also loads some system-wide settings that bash -l does not (like user groups).






                    share|improve this answer






















                    • important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                      – underscore_d
                      Sep 24 '15 at 0:40












                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    su -l yourOwnUserName


                    Will open a fresh shell for yourOwnUserName user with all the settings re-loaded. This is shell-independent, as it refers to system settings, not your specific shell. It also loads some system-wide settings that bash -l does not (like user groups).






                    share|improve this answer














                    su -l yourOwnUserName


                    Will open a fresh shell for yourOwnUserName user with all the settings re-loaded. This is shell-independent, as it refers to system settings, not your specific shell. It also loads some system-wide settings that bash -l does not (like user groups).







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Oct 17 '11 at 12:36

























                    answered Oct 17 '11 at 12:19









                    rozcietrzewiacz

                    28.2k37191




                    28.2k37191











                    • important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                      – underscore_d
                      Sep 24 '15 at 0:40
















                    • important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                      – underscore_d
                      Sep 24 '15 at 0:40















                    important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                    – underscore_d
                    Sep 24 '15 at 0:40




                    important note: "a fresh shell" here means a shell within your existing shell, so you are only nesting shells, not replacing your original one. The accepted answer does that properly.
                    – underscore_d
                    Sep 24 '15 at 0:40

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f22721%2fcompletely-restart-bash%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?