Learn by reading through in order

Using the Terminal Faster — Completion, History, Line Editing

Practice Tab completion, reusing history with the arrow keys and history, line editing with Ctrl-A/Ctrl-E/Ctrl-U, and history search with Ctrl-R, hands-on in a browser terminal.

Completion and History — Tab and Arrow Keys

Type part of a name and press the Tab key, and the terminal fills in the filename or command for you (completion).

Commands you've typed stay in the history, and you can recall and reuse them with the up/down arrow keys.

This saves you from typing long filenames and commands every time.

history is a command that lists the commands you've typed with numbers.

For a long command you use often, recalling it from history instead of retyping is faster and more accurate.

Key / CommandAction
TabComplete a filename or command you're typing
↑ / ↓Recall the previous/next item in history
historyList the commands you've typed, with numbers
clearScroll the display away and start fresh
Completion and history operations
Tab keyCompletes a nameto save typingUp/down arrow keysRecall the previous/nextitem in historyhistoryLists historywith numbers
Tab completes, arrow keys recall history, and history lists it.
touch report_2026.txt   # file to practice completion
ls rep[Tab]             # type rep then Tab → completes to report_2026.txt
ls report_2026.txt      # recall with the up arrow and rerun

① Create a file to practice completion with touch report_2026.txt.

② Type up to ls rep, then press the Tab key and confirm the filename is completed automatically before pressing Enter.

③ Press the up arrow key to recall the previous ls command and run it again with Enter.

④ Run echo done.

⑤ Recall echo done again with the up arrow and confirm you can rerun it with Enter. (Run it correctly and an explanation will appear.)

Linux console
0 / 2 completed
Loading Linux Terminal...

Listing History and Clearing the Screen — history / clear

history is an actual command you type that shows the commands you've entered, with numbers.

When the screen fills with output, clear scrolls it away so you can start from a blank screen.

Neither is a keystroke — they're commands, so type them and run with Enter.

echo first    # stays in history
echo second   # stays in history
history       # list the commands so far, with numbers
clear         # scroll the display away and start fresh

① Run echo alpha and echo beta in order.

② Run history and confirm the commands you just typed appear in a numbered list.

③ Run clear and confirm the display scrolls away and goes blank.

Linux console
0 / 4 completed
Loading Linux Terminal...

Line Editing and Control — Ctrl Shortcuts

When you need to fix the start of a long command you're typing, going back one character at a time with the arrow keys is slow.

With Ctrl-key combinations, you can jump straight to the start or end of the line or delete input in bulk.

Ctrl-key combinations fall into three roles: moving, deleting, and control.

The table below organizes what each one does.

KeyAction
Ctrl-AMove to the start of the line
Ctrl-EMove to the end of the line
Ctrl-UDelete everything before the cursor
Ctrl-KDelete everything after the cursor
Ctrl-WDelete the previous word
Ctrl-LClear the screen
Ctrl-CInterrupt the running process
Ctrl-DSend end-of-input (EOF)
Line-editing and control keys
Ctrl-A / Ctrl-EMove to line start / endCtrl-U / Ctrl-K / Ctrl-WDelete before /after / a wordCtrl-L / Ctrl-C / Ctrl-DClear screen / interrupt/ end input
Hold Ctrl to move, delete, and control quickly.
echo this is a long line   # type it, then Ctrl-A to the line start
# Ctrl-E back to the end, Ctrl-U to wipe the whole line
sleep 5                    # a command that just waits 5 seconds. Ctrl-C to interrupt while running

① Type echo this is a long line, and without pressing Enter yet, press Ctrl-A to confirm the cursor jumps to the start of the line.

② Then go back to the end of the line with Ctrl-E.

③ Type sleep 5 (a command that just waits 5 seconds) and run it with Enter, then press Ctrl-C while it waits to confirm the process is interrupted (the prompt comes back).

Linux console
Loading Linux Terminal...

① Type echo aaa bbb ccc, and without pressing Enter, press Ctrl-W to confirm only the previous word (ccc) is deleted.

② Then press Ctrl-U to confirm everything before the cursor (the whole line you're typing) is deleted at once.

③ Type echo hello world again, move to the line start with Ctrl-A, then press Ctrl-K to confirm everything after the cursor is deleted.

④ Finally press Ctrl-L to confirm only the display is cleared and goes blank (the history stays).

Linux console
Loading Linux Terminal...

Searching History — Ctrl-R

Pressing Ctrl-R enters the history search mode, and as you type, matching past commands appear as candidates.

When the one you want appears, press Enter to run it or Ctrl-C to leave the search.

With a candidate showing, pressing Tab pulls the command onto the input line without running it, so you can check or edit it before running.

Since you can recall a long command with just a few characters, it's faster than scrolling back forever with the arrow keys.

How searching history with Ctrl-R works
Press Ctrl-REnter history search modeType charactersMatching history appearsas a candidateTab / Enter / Ctrl-CPull onto line /run / cancel
Ctrl-R starts the search, type to narrow it, Enter to run, Ctrl-C to leave.

① First run echo searchme to leave it in the history.

② Press Ctrl-R to enter search mode, type sea, and confirm echo searchme appears as a candidate.

③ Press Tab to confirm the command is pulled onto the input line without running (you can check or edit it here).

④ Then press Enter to run it, or Ctrl-C to cancel.

Linux console
Loading Linux Terminal...

!! and !$ on Ubuntu and others

In bash on Ubuntu and similar systems, !! recalls the previous command and !$ the last word of the previous line (history expansion).

This course's console (busybox) doesn't support history expansion, so here we reuse history with Ctrl-R and the up/down keys.

QUIZ

Knowledge Check

Answer each question one by one.

Q1Which key do you press to have the terminal complete a filename you've started typing?

Q2Which do you press to interrupt a running process?

Q3Which command lists the commands you've typed, with numbers?