Live data from Hacker News

What typing ^D does on Unix (2009)

utcc.utoronto.ca

11–20 of 162 posts

Re: What typing ^D does on Unix (2009)

#12
post #9
post #7

Earlier quoted context omitted.

nice one, never seen that - always used ^D/exit

Those are yet more graceful -- for when the shell is responsive. Use ~. in cases where for some reason you cannot get access to the terminal anymore but remote sshd is responsive.

~. (and the other ~ commands) are handled locally, not by the remote sshd. I use it when my network cuts out or something and my ssh session is unrecoverably stuck

Re: What typing ^D does on Unix (2009)

#13
post #11

^U will clear the buffer - super convenient for retrying botched passwords.

^Y will paste the cleared buffer back again

So ^U will let a partial password linger in memory longer than it needs to if you use it as suggested by the GP?

Re: What typing ^D does on Unix (2009)

#14
post #9
post #7

Earlier quoted context omitted.

nice one, never seen that - always used ^D/exit

Those are yet more graceful -- for when the shell is responsive. Use ~. in cases where for some reason you cannot get access to the terminal anymore but remote sshd is responsive.

Actually the remote sshd does not need to be responsive, because "~." is interpreted by the local ssh client. Very convenient if the TCP connection is stuck.

You can also type "~?" for a list of other commands supported by the local ssh client. Among other things, "~C" opens a command line interpreter on the client side of the ssh client, allowing you to add and remove TCP port forwarding without restarting the connection.

Re: What typing ^D does on Unix (2009)

#15
post #13
post #11

Earlier quoted context omitted.

^Y will paste the cleared buffer back again

So ^U will let a partial password linger in memory longer than it needs to if you use it as suggested by the GP?

No, I don't think so. Not unless you are accustomed to typing your password directly into the terminal prompt. Kill buffers don't pass from one application to another and they don't all behave the same in every context, either.

(For example, if I type some stuff and then ^U to kill the password buffer at an SSH password prompt, typing ^Y after that seems to put the whole process in the background. Not sure what that's intended to do, but subsequent ^Y presses don't retrieve the password into the shell prompt...)

Re: What typing ^D does on Unix (2009)

#16
post #9
post #7

Earlier quoted context omitted.

nice one, never seen that - always used ^D/exit

Those are yet more graceful -- for when the shell is responsive. Use ~. in cases where for some reason you cannot get access to the terminal anymore but remote sshd is responsive.

You can also layer the number of ~'s to skip over intermediary SSH sessions and send the escape to the proper one.

\n~~. will escape the 2nd box you've SSH'd to, not the one it was originated from.

Useful for escaping a screen'd SSH session that you might access through a jumphost.

Re: What typing ^D does on Unix (2009)

#18
post #11

^U will clear the buffer - super convenient for retrying botched passwords.

^Y will paste the cleared buffer back again

Actually, this is a feature of libreadline (in its default configuration). ^Y mimics the yank command from emacs. At an actual terminal input (like you can get by running `cat` with no arguments), ^Y will just echo back a literal ^Y (assuming it too is in its default configuration).

Re: What typing ^D does on Unix (2009)

#20

Pressing enter then ~. will gracefully shutdown hung ssh sessions

Sadly it will shutdown only the 'outer' ssh session, so if you ssh to foo, and then from foo ssh to bar, and type ~. then the client->foo session is shut down but the foo->bar session is still around.
Post reply on HN