Shell Shortcuts That Save Time

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
history

In 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:

TypeRuns
!!The previous command again
!3Command number 3 from the history list
Ctrl + RSearch back through history: start typing any part of an old command

Keyboard shortcuts

KeysWhat it does
Ctrl + CStop the running command, or throw away what you were typing
Ctrl + LClear the screen (the same as the clear command)
Ctrl + AJump to the start of the line
Ctrl + EJump to the end of the line
Ctrl + UDelete everything before the cursor
Ctrl + WDelete the word before the cursor
Ctrl + DOn 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.

HOME LEARN COMMUNITY DASHBOARD
Practice terminal Starting…