Linux Labs

First steps / Stage 3 of 15

Working comfortably in the terminal

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 8 · on a machine · 4 min

Edit the line before Enter

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
Warning

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.

Exercise · look

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.

Sign in and start The machine is available after signing in
Ubuntu 24.04
Loading…