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
How to make a list of partial sums using forEach
El Dorado Word Puzzle II: Videogame Edition
What is the meaning of "You've never met a graph you didn't like?"
Limit max CPU usage SQL SERVER with WSRM
Did I make a mistake by ccing email to boss to others?
Animation: customize bounce interpolation
Where are they being held?
Possible Eco thriller, man invents a device to remove rain from glass
What is the tangent at a sharp point on a curve?
Given this phrasing in the lease, when should I pay my rent?
Can I run 125khz RF circuit on a breadboard?
How to make money from a browser who sees 5 seconds into the future of any web page?
How much do grades matter for a future academia position?
PTIJ: does fasting on Ta'anis Esther give us reward as if we celebrated 2 Purims? (similar to Yom Kippur)
Conflicting names of my great grandmother's parents
Identifying "long and narrow" polygons in with Postgis
How to preserve electronics (computers, iPads and phones) for hundreds of years
Why would five hundred and five be same as one?
Echo with obfuscation
How to understand "he realized a split second too late was also a mistake"
Storage of electrolytic capacitors - how long?
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Typing CO_2 easily
Make a Bowl of Alphabet Soup
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
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
add a comment |
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
2
~.
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 withSIGHUP
, 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
2 days ago
add a comment |
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
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
bash shell session
asked 2 days ago
tsujptsujp
320211
320211
2
~.
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 withSIGHUP
, 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
2 days ago
add a comment |
2
~.
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 withSIGHUP
, 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
2 days ago
2
2
~.
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
2 days 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
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
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.
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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 anrm
command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.
– Peschke
2 days ago
2
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
Peschke is using thevi
terminal input bindings.
– JdeBP
yesterday
|
show 3 more comments
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.
New contributor
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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 anrm
command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.
– Peschke
2 days ago
2
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
Peschke is using thevi
terminal input bindings.
– JdeBP
yesterday
|
show 3 more comments
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.
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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 anrm
command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.
– Peschke
2 days ago
2
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
Peschke is using thevi
terminal input bindings.
– JdeBP
yesterday
|
show 3 more comments
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.
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.
edited 2 days ago
DopeGhoti
46.4k56190
46.4k56190
answered 2 days ago
0xSheepdog0xSheepdog
1,5321924
1,5321924
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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 anrm
command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.
– Peschke
2 days ago
2
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
Peschke is using thevi
terminal input bindings.
– JdeBP
yesterday
|
show 3 more comments
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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 anrm
command and then hit CTRL+D if you didn’t want to execute it. I don’t see this behavior in ksh.
– Peschke
2 days ago
2
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
Peschke is using thevi
terminal input bindings.
– JdeBP
yesterday
2
2
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days ago
The next stop is unix.stackexchange.com/a/182071/5132 , and the stop after that is the further reading there. (-:
– JdeBP
2 days 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
2 days 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
2 days ago
2
2
@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
yesterday
@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
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
@JohnKugelman I tested and confirmed the behavior at the time of my comment with bash on RHEL 7.5.
– Peschke
yesterday
2
2
Peschke is using the
vi
terminal input bindings.– JdeBP
yesterday
Peschke is using the
vi
terminal input bindings.– JdeBP
yesterday
|
show 3 more comments
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.
New contributor
add a comment |
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.
New contributor
add a comment |
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.
New contributor
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.
New contributor
New contributor
answered 2 days ago
LL3LL3
511
511
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
2
~.
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 withSIGHUP
, 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
2 days ago