The shell will read commands from your terminal (i.e. the shell's standard input) until it's told to stop (by entering the exit
command) or when an end-of-file (EOF) is encountered (just like when the shell is executing a script).
If you enter the exit
command, this will first be saved into the history, and then the shell will quit. Entering ctrl-D generates an EOF; as this is not a command but an input state, it can't be saved in the shell's history.
Note that you can instruct bash
to ignore EOF; this can be done in 2 ways:
- set -o ignoreeof
- IGNOREEOF=
n
The first way is equivalent to doing IGNOREEOF=10
, meaning you have to hit ctrl-D 10 times in a row before the shell will exit. This is to prevent accidentally terminating the shell e.g. if you mistype ctrl-C or whatever.
Note also that ctrl-D only generates an EOF
when entered as the first thing on a line (i.e. after an enter), bash
ignores it if anything has already been typed on the line.
The ctrl-D also generates EOF
outside the shell. E.g.:
$ wc
foo bar
<ctrl-D>
1 2 8
wc
has counted 1 line, 2 words, 8 characters (including the newline).
Here's an example with using ctrl-D after some input has been given on the line:
$ wc
foo bar<ctrl-D><ctrl-D> 0 2 7
Now wc
has counted zero lines (no enter
had been given), 2 words and 7 characters. Two ctrl-D sequences were necessary because data had already been given; note that bash
handles this specially (ignoring the EOF
if something has already been entered on the line), whereas e.g. dash
doesn't. This is probably due to the line editing facility in bash
.
screen
would be a good idea. It will allow you to get back into your previous session with everything intact. – Barmar Mar 04 '15 at 21:42ServerAliveInterval 30
to your~/.ssh/config
, they may be killing idle connections. – Stéphane Chazelas Mar 04 '15 at 21:45exit
at the end of the day otherwise it would log the entire night as downtime. – NobleUplift Mar 04 '15 at 21:50HISTIGNORE=exit
does seem to be working for me. ButCTRL+D
works great! It would be nice to getHISTIGNORE
working through. – NobleUplift Mar 05 '15 at 17:24