Exit shell with shortcut (not typing exit) that closes session properly2019 Community Moderator ElectionWhy does Ctrl-D (EOF) exit the shell?ksh - map Ctrl-D to exit shellHow to exit out of the shell script successfully so that python subprocess think it is successfull exit?Bash script for scp interpreting tilde (~) too soonGUI terminals(?) reset $SHELLCross-session duplicate removal in bash command historyhow to write own shell that works with sshHow to account for shell-session env vars, contexts with chrootAny command in my terminal that exits with non-zero code closes my terminal windowHere-document not working properly on shell scriptHow to properly write and execute a shell script and exit correctly?Securely Piping String in Local Text File to Remote Command using SSH

Did Nintendo change its mind about 68000 SNES?

Why do I have a large white artefact on the rendered image?

Why doesn't the chatan sign the ketubah?

What are the rules for concealing thieves' tools (or items in general)?

Should I be concerned about student access to a test bank?

Why is participating in the European Parliamentary elections used as a threat?

What is the reasoning behind standardization (dividing by standard deviation)?

When should a starting writer get his own webpage?

Print last inputted byte

"Marked down as someone wanting to sell shares." What does that mean?

What is the difference between something being completely legal and being completely decriminalized?

Jem'Hadar, something strange about their life expectancy

Friend wants my recommendation but I don't want to

How do you justify more code being written by following clean code practices?

What is the tangent at a sharp point on a curve?

PTIJ: Which Dr. Seuss books should one obtain?

Why is "la Gestapo" feminine?

Do I need an EFI partition for each 18.04 ubuntu I have on my HD?

Hackerrank All Women's Codesprint 2019: Name the Product

Extraneous elements in "Europe countries" list

How can a new country break out from a developed country without war?

Air travel with refrigerated insulin

Nested Dynamic SOQL Query

10 year ban after applying for a UK student visa



Exit shell with shortcut (not typing exit) that closes session properly



2019 Community Moderator ElectionWhy does Ctrl-D (EOF) exit the shell?ksh - map Ctrl-D to exit shellHow to exit out of the shell script successfully so that python subprocess think it is successfull exit?Bash script for scp interpreting tilde (~) too soonGUI terminals(?) reset $SHELLCross-session duplicate removal in bash command historyhow to write own shell that works with sshHow to account for shell-session env vars, contexts with chrootAny command in my terminal that exits with non-zero code closes my terminal windowHere-document not working properly on shell scriptHow to properly write and execute a shell script and exit correctly?Securely Piping String in Local Text File to Remote Command using SSH










8















I use a ProxyJump command for a number of ssh sessions I use daily, and also switch users a lot on these sessions and having to type exit 3 or 4 times in a row isn't too fun.



I am aware of newline + ~ + . to terminate an ssh session, I still have to check if it terminates it amicably like an exit would, but how do you exit all sessions in the current shell with a single command or shortcut such that typing exit 3 or 4 times in my case becomes a one-time thing?










share|improve this question

















  • 1





    ~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

    – Toby Speight
    6 hours ago















8















I use a ProxyJump command for a number of ssh sessions I use daily, and also switch users a lot on these sessions and having to type exit 3 or 4 times in a row isn't too fun.



I am aware of newline + ~ + . to terminate an ssh session, I still have to check if it terminates it amicably like an exit would, but how do you exit all sessions in the current shell with a single command or shortcut such that typing exit 3 or 4 times in my case becomes a one-time thing?










share|improve this question

















  • 1





    ~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

    – Toby Speight
    6 hours ago













8












8








8








I use a ProxyJump command for a number of ssh sessions I use daily, and also switch users a lot on these sessions and having to type exit 3 or 4 times in a row isn't too fun.



I am aware of newline + ~ + . to terminate an ssh session, I still have to check if it terminates it amicably like an exit would, but how do you exit all sessions in the current shell with a single command or shortcut such that typing exit 3 or 4 times in my case becomes a one-time thing?










share|improve this question














I use a ProxyJump command for a number of ssh sessions I use daily, and also switch users a lot on these sessions and having to type exit 3 or 4 times in a row isn't too fun.



I am aware of newline + ~ + . to terminate an ssh session, I still have to check if it terminates it amicably like an exit would, but how do you exit all sessions in the current shell with a single command or shortcut such that typing exit 3 or 4 times in my case becomes a one-time thing?







bash shell session






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









tsujptsujp

30329




30329







  • 1





    ~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

    – Toby Speight
    6 hours ago












  • 1





    ~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

    – Toby Speight
    6 hours ago







1




1





~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

– Toby Speight
6 hours ago





~. just disconnects your SSH client (it's useful when the network has disappeared, for example). Normally, the SSH daemon will recognise that and signal its session with SIGHUP, so it's not quite the same as quitting the shell normally (but it's useful if you can't get any response from the shell).

– Toby Speight
6 hours ago










2 Answers
2






active

oldest

votes


















17














Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.



Discussed in detail here.






share|improve this answer




















  • 2





    The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

    – JdeBP
    7 hours ago











  • Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

    – Peschke
    5 hours ago







  • 1





    @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

    – John Kugelman
    4 hours ago











  • @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

    – Peschke
    4 hours ago


















0














Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.



It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.



Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.






share|improve this answer








New contributor




LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















    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%2f507011%2fexit-shell-with-shortcut-not-typing-exit-that-closes-session-properly%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    17














    Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.



    Discussed in detail here.






    share|improve this answer




















    • 2





      The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

      – JdeBP
      7 hours ago











    • Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

      – Peschke
      5 hours ago







    • 1





      @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

      – John Kugelman
      4 hours ago











    • @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

      – Peschke
      4 hours ago















    17














    Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.



    Discussed in detail here.






    share|improve this answer




















    • 2





      The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

      – JdeBP
      7 hours ago











    • Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

      – Peschke
      5 hours ago







    • 1





      @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

      – John Kugelman
      4 hours ago











    • @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

      – Peschke
      4 hours ago













    17












    17








    17







    Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.



    Discussed in detail here.






    share|improve this answer















    Ctrl-D will exit a shell in many cases. It is quicker than typing exit Enter. It's still not a single command to terminate everything, but holding Ctrl and hitting D several times is easier and faster. Not sure how valuable this is for your use case.



    Discussed in detail here.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 8 hours ago









    DopeGhoti

    46.3k56089




    46.3k56089










    answered 8 hours ago









    0xSheepdog0xSheepdog

    1,4171623




    1,4171623







    • 2





      The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

      – JdeBP
      7 hours ago











    • Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

      – Peschke
      5 hours ago







    • 1





      @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

      – John Kugelman
      4 hours ago











    • @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

      – Peschke
      4 hours ago












    • 2





      The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

      – JdeBP
      7 hours ago











    • Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

      – Peschke
      5 hours ago







    • 1





      @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

      – John Kugelman
      4 hours ago











    • @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

      – Peschke
      4 hours ago







    2




    2





    The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

    – JdeBP
    7 hours ago





    The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:

    – JdeBP
    7 hours ago













    Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

    – Peschke
    5 hours ago






    Be careful with CTRL+D. In bash, if you have input any characters in your prompt, hitting CTRL+D will execute it the same way Enter would. In other words, don’t type out an rm command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.

    – Peschke
    5 hours ago





    1




    1





    @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

    – John Kugelman
    4 hours ago





    @Peschke On every system I've ever used Ctrl+D does nothing if I've typed something. I've never seen the behavior you describe.

    – John Kugelman
    4 hours ago













    @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

    – Peschke
    4 hours ago





    @JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.

    – Peschke
    4 hours ago













    0














    Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.



    It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.



    Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.






    share|improve this answer








    New contributor




    LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      0














      Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.



      It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.



      Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.






      share|improve this answer








      New contributor




      LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        0












        0








        0







        Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.



        It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.



        Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.






        share|improve this answer








        New contributor




        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        Typing ~. actually does the trick of closing all the "nested" connections through to the deepest.



        It does so with the amicable exit you want as long as all your shells are configured to handle SIGHUP as a graceful death. Bash does so by default. You can easily check the amicable exit for your set-up by e.g. seeing whether the .bash_history files of your deeper sessions get properly updated after the ~., or if you set your bash-es not to update .bash_history upon exit then you might set a trap on the EXIT event (or in your ~/.bash_logout) with a command that writes something somewhere and later see whether it got executed.



        Besides, I’m not sure what you mean by "exit all sessions in current shell". Each interactive bash is just one session, and the commands you type go always only to the deepest shell of the ProxyJump chain. If you meant "the background jobs in the current shell", bash does send SIGHUP to all its jobs on receiving SIGHUP by the ssh daemon upon the ~. , therefore such exit should be fully amicable if those running jobs react properly to a SIGHUP.







        share|improve this answer








        New contributor




        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 5 hours ago









        LL3LL3

        1




        1




        New contributor




        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        LL3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507011%2fexit-shell-with-shortcut-not-typing-exit-that-closes-session-properly%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

            Благоевград Съдържание География | История | Население | Политика | Икономика и инфрастуктура | Здравеопазване | Образование и наука | Култура и забавления | Забележителности | Личности | Литература | Външни препратки | Бележки | Навигация42°01′18.99″ с. ш. 23°05′51″ и. д. / 42.021944° с. ш. 23.0975° и. д.*БлагоевградразширитередактиранеОфициален уебсайт на община БлагоевградНовинарски портал на Благоевград – blagoevgrad.euСайтове за БлагоевградНационален статистически институтdariknews.bgГригоровичъ, Викторъ. „Очеркъ путешествія по Европейской Турціи“. Москва, 1877.Стрезов, Георги. Два санджака от Източна Македония. Периодично списание на Българското книжовно дружество в Средец, кн. XXXVII и XXXVIII, 1891, стр. 18 – 19.Македония. Етнография и статистикаГаджанов, Димитър Г. Мюсюлманското население в Новоосвободените земи, в: Научна експедиция в Македония и Поморавието 1916, Военноиздателски комплекс „Св. Георги Победоносец“, Университетско издателство „Св. Климент Охридски“, София, 1993, стр. 244.паметник на незнайния четник&cd=18&hl=en&ct=clnk&client=firefox-a „История на днешен Благоевград“, взето от www.museumblg.com на 16 март 2010 г.„Справка за населението на град Благоевград, община Благоевград, област Благоевград, НСИ“„The population of all towns and villages in Blagoevgrad Province with 50 inhabitants or more according to census results and latest official estimates“„Ethnic composition, all places: 2011 census“История на Неврокопска епархия.Национален статистически институтМюсюлманско изповедание. Главно мюфтийствоНационален публичен регистър на храмовете в БългарияМюсюлманско изповедание. Главно мюфтийствоwww.dnes.bg Джамията в Благоевград не била паленаwww.sesc-bg.orgСписък на побратимени градовеТехническо побратимяванеГУМ грейва в цветовете на нощен Лас Вегас под името „Largo“, „МОЛ Благоевград“..., в. „Струма“grabo.bgwww.cinemaxbg.comррр4238731-067cad53a-0546-417b-a3d3-51e49b1d2232147736077147736077

            What is the best defense strategy for Survival in Grand Theft Auto Online?What is JP used for in Grand Theft Auto Online?How do I setup a Crew HQ in Grand Theft Auto Online?How does stealth work in Grand Theft Auto Online?Is it possible to own more than 10 cars in Grand Theft Auto online?Where to find truck/trailers in Grand Theft Auto OnlineWhat are some of the best missions to do on Grand Theft Auto 5 onlineFastest Car in Grand Theft Auto V PCHow to setup a Crew vs Crew online session in Grand Theft Auto Online?Grand theft auto 5 crossplayingRestart Grand Theft Auto V Online?

            How does Billy Russo acquire his 'Jigsaw' mask? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why does Bane wear the mask?Why does Kylo Ren wear a mask?Why did Captain America remove his mask while fighting Batroc the Leaper?How did the OA acquire her wisdom?Is Billy Breckenridge gay?How does Adrian Toomes hide his earnings from the IRS?What is the state of affairs on Nootka Sound by the end of season 1?How did Tia Dalma acquire Captain Barbossa's body?How is one “Deemed Worthy”, to acquire the Greatsword “Dawn”?How did Karen acquire the handgun?