Does exiting a login shell necessarily log out of the OS?

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












-5














Bash manual says




logout [n]



Exit a login shell, returning a status of n to the shell’s parent.




On a virtual console of Ubuntu, I first log in, and in the login shell, run:



$ pstree -paus $$
systemd,1 --system --deserialize 19
`-login,30488 -p --
`-bash,31728,t
`-pstree,31774 -paus 31728


and then run logout, and all the processes starting from login,30488 till below disappear, more than just "return to the shell's parent" which is thelogin process.



In a login bash shell , does bash builtin commandlogout log out of the OS, not just exit the shell?



Does exiting a login shell (not necessarily by logout, but also any other way, such as bash builtin exit among others) necessarily lead to logging out of the OS?



May I also ask what logging out of OS means?



Thanks.




Extended to: https://stackoverflow.com/questions/53887813/how-does-the-login-program-in-linux-invoke-a-login-shell










share|improve this question




























    -5














    Bash manual says




    logout [n]



    Exit a login shell, returning a status of n to the shell’s parent.




    On a virtual console of Ubuntu, I first log in, and in the login shell, run:



    $ pstree -paus $$
    systemd,1 --system --deserialize 19
    `-login,30488 -p --
    `-bash,31728,t
    `-pstree,31774 -paus 31728


    and then run logout, and all the processes starting from login,30488 till below disappear, more than just "return to the shell's parent" which is thelogin process.



    In a login bash shell , does bash builtin commandlogout log out of the OS, not just exit the shell?



    Does exiting a login shell (not necessarily by logout, but also any other way, such as bash builtin exit among others) necessarily lead to logging out of the OS?



    May I also ask what logging out of OS means?



    Thanks.




    Extended to: https://stackoverflow.com/questions/53887813/how-does-the-login-program-in-linux-invoke-a-login-shell










    share|improve this question


























      -5












      -5








      -5







      Bash manual says




      logout [n]



      Exit a login shell, returning a status of n to the shell’s parent.




      On a virtual console of Ubuntu, I first log in, and in the login shell, run:



      $ pstree -paus $$
      systemd,1 --system --deserialize 19
      `-login,30488 -p --
      `-bash,31728,t
      `-pstree,31774 -paus 31728


      and then run logout, and all the processes starting from login,30488 till below disappear, more than just "return to the shell's parent" which is thelogin process.



      In a login bash shell , does bash builtin commandlogout log out of the OS, not just exit the shell?



      Does exiting a login shell (not necessarily by logout, but also any other way, such as bash builtin exit among others) necessarily lead to logging out of the OS?



      May I also ask what logging out of OS means?



      Thanks.




      Extended to: https://stackoverflow.com/questions/53887813/how-does-the-login-program-in-linux-invoke-a-login-shell










      share|improve this question















      Bash manual says




      logout [n]



      Exit a login shell, returning a status of n to the shell’s parent.




      On a virtual console of Ubuntu, I first log in, and in the login shell, run:



      $ pstree -paus $$
      systemd,1 --system --deserialize 19
      `-login,30488 -p --
      `-bash,31728,t
      `-pstree,31774 -paus 31728


      and then run logout, and all the processes starting from login,30488 till below disappear, more than just "return to the shell's parent" which is thelogin process.



      In a login bash shell , does bash builtin commandlogout log out of the OS, not just exit the shell?



      Does exiting a login shell (not necessarily by logout, but also any other way, such as bash builtin exit among others) necessarily lead to logging out of the OS?



      May I also ask what logging out of OS means?



      Thanks.




      Extended to: https://stackoverflow.com/questions/53887813/how-does-the-login-program-in-linux-invoke-a-login-shell







      bash logout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 21 '18 at 16:46

























      asked Dec 21 '18 at 2:32









      Tim

      26.1k74246455




      26.1k74246455




















          1 Answer
          1






          active

          oldest

          votes


















          2














          In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section).



          In your example, you can see process 31728 is called -bash, so begins with a - and so was invoked as a login shell.



          logout simply exits a login shell.



          So if you run bash -l and then logout you'll find yourself back at the calling shell.



          $ echo $$
          32145
          $ bash -l
          bash-4.2$ logout
          $ echo $$
          32145


          Now the login program (process 30488 in your example) waits for the child shell to exit, then performs some cleanup actions (eg wtmp, utmp) then exits. That is why you no longer see this process after running logout.






          share|improve this answer






















            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f490251%2fdoes-exiting-a-login-shell-necessarily-log-out-of-the-os%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section).



            In your example, you can see process 31728 is called -bash, so begins with a - and so was invoked as a login shell.



            logout simply exits a login shell.



            So if you run bash -l and then logout you'll find yourself back at the calling shell.



            $ echo $$
            32145
            $ bash -l
            bash-4.2$ logout
            $ echo $$
            32145


            Now the login program (process 30488 in your example) waits for the child shell to exit, then performs some cleanup actions (eg wtmp, utmp) then exits. That is why you no longer see this process after running logout.






            share|improve this answer



























              2














              In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section).



              In your example, you can see process 31728 is called -bash, so begins with a - and so was invoked as a login shell.



              logout simply exits a login shell.



              So if you run bash -l and then logout you'll find yourself back at the calling shell.



              $ echo $$
              32145
              $ bash -l
              bash-4.2$ logout
              $ echo $$
              32145


              Now the login program (process 30488 in your example) waits for the child shell to exit, then performs some cleanup actions (eg wtmp, utmp) then exits. That is why you no longer see this process after running logout.






              share|improve this answer

























                2












                2








                2






                In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section).



                In your example, you can see process 31728 is called -bash, so begins with a - and so was invoked as a login shell.



                logout simply exits a login shell.



                So if you run bash -l and then logout you'll find yourself back at the calling shell.



                $ echo $$
                32145
                $ bash -l
                bash-4.2$ logout
                $ echo $$
                32145


                Now the login program (process 30488 in your example) waits for the child shell to exit, then performs some cleanup actions (eg wtmp, utmp) then exits. That is why you no longer see this process after running logout.






                share|improve this answer














                In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section).



                In your example, you can see process 31728 is called -bash, so begins with a - and so was invoked as a login shell.



                logout simply exits a login shell.



                So if you run bash -l and then logout you'll find yourself back at the calling shell.



                $ echo $$
                32145
                $ bash -l
                bash-4.2$ logout
                $ echo $$
                32145


                Now the login program (process 30488 in your example) waits for the child shell to exit, then performs some cleanup actions (eg wtmp, utmp) then exits. That is why you no longer see this process after running logout.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 21 '18 at 5:18









                Stephen Kitt

                164k24365445




                164k24365445










                answered Dec 21 '18 at 2:54









                Stephen Harris

                25.1k24477




                25.1k24477



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f490251%2fdoes-exiting-a-login-shell-necessarily-log-out-of-the-os%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 check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay