Tab completion
Press Tab while typing and the shell finishes the word for you. Type ls Doc and press Tab: it becomes ls Documents/.
If more than one name matches, nothing happens on the first press. Press Tab twice to see all the choices, type a few more letters, and press Tab again.
Tip: Use Tab all the time. It is faster, and it prevents typos: if Tab can't complete a name, the file probably isn't there.
Command history
The shell remembers what you typed. Press ↑ to bring back the previous command, again to go further back, and ↓ to go forward. Press Enter to run it again, or edit it first.
The history command lists everything you have typed, with a number for each:
echo first
echo second
historyIn the terminal
student@vulntech:~$ echo first first student@vulntech:~$ echo second second student@vulntech:~$ history 1 echo first 2 echo second 3 history
A few history tricks:
| Type | Runs |
|---|---|
!! | The previous command again |
!3 | Command number 3 from the history list |
| Ctrl + R | Search back through history: start typing any part of an old command |
Keyboard shortcuts
| Keys | What it does |
|---|---|
| Ctrl + C | Stop the running command, or throw away what you were typing |
| Ctrl + L | Clear the screen (the same as the clear command) |
| Ctrl + A | Jump to the start of the line |
| Ctrl + E | Jump to the end of the line |
| Ctrl + U | Delete everything before the cursor |
| Ctrl + W | Delete the word before the cursor |
| Ctrl + D | On an empty line: log out of the shell |
Tip: A few shortcuts belong to your web browser, not the terminal: in the lab terminal, Ctrl+W may close the browser tab. Use Ctrl+U to clear a line instead. In a real terminal app, Ctrl+W works as described.
Common mistake: Ctrl+C does not copy in a terminal: it stops the running command. In the lab terminal, select text with the mouse to copy it.
Remember: Tab to complete, ↑ for history, Ctrl+C to stop, Ctrl+L to clear.