Bash keeps a record of your previous commands - try using the up and down arrow keys (or Ctrl-p / Ctrl-n) to cycle through history.

If you want to see a bunch of history at once, try the history command. This can get long, so try piping it to tail:

pi@raspberrypi ~ $ history | tail
   92  help history
   93  help history|less
   94  cowthink what?
   95  cowthink 'what?'
   96  history
   97  man history
   98  help history
   99  history | head -1
  100  history | head
  101  history | tail

Suppose you remember part of a command, and want to reuse it?

Try typing Ctrl-r, followed by the part of the command you remember. Bash will search the history for matches. You can then press Enter to execute the command over again, or Esc to edit it.

Tab Completion

Often, you know the name of a command or file, but it would be nice not to have to type the whole thing. Try typing the first few letters of a command and hit Tab. Bash will attempt to find a matching command and fill it in for you. If there's more than one command that matches, you may need to hit Tab again, and you'll be presented with a list of possible commands.

Similarly, typing part of a file name and pressing Tab will often complete the name. If more than one file matches what you've already typed, hit Tab a couple of times and you'll get a list of files.

Line Editing

If you need to fix a typo or revise an earlier command you've retrieved from history, Bash provides a set of editing commands.

Ctrl-b or left arrow key

Move back one character

Ctrl-f or right arrow

Move forward one character

Ctrl-a or Home

Move to beginning of line

Ctrl-e or End

Move to end of line


Kill (delete/cut) text from cursor position to end of line


Yank (paste) previously killed text

There's more - check out the manual on Readline Interaction.

This guide was first published on Feb 24, 2015. It was last updated on Feb 24, 2015.

This page (Use History, Tab Completion, and Line Editing) was last updated on Feb 22, 2015.

Text editor powered by tinymce.