Until you press Enter, a command is only text on the line. A typo in the middle gets fixed in place, without retyping the whole thing.
The terminal hands your keystrokes to whichever program is running. In the log that was less, and the arrow scrolled the text. At the prompt the shell reads the keys: it edits the line until Enter and remembers earlier commands, which is why the Up arrow brought back less notes.txt.
Ctrl+A means: hold Ctrl and press A. Click the terminal before a shortcut, or the browser gets the keypress.
| Press | What happens |
|---|---|
| ← → | the cursor moves one character |
| Ctrl+A, Ctrl+E | the cursor jumps to the start or the end of the line |
| Alt+Backspace | the word before the cursor is erased |
| Ctrl+U | everything before the cursor is erased |
| Ctrl+K | everything from the cursor to the end of the line is erased |
In a browser Ctrl+W closes the tab, even though many guides use it to erase a word. Here, erase a word with Alt+Backspace.
Erase the end of the line
echo prints the words you give it. Type echo one two three without pressing Enter. Use the Left arrow to put the cursor on the first letter of two, press Ctrl+K, then Enter.