Useful Shortcuts

You’ve already learned that typing cd returns you to your home directory. This is just one of the many shortcuts available on the command line.

First, if you press the Up arrow key on your keyboard, the previous command you issued will appear on the command line. Press Enter to execute it again. Or press Up again to see the command you typed before that. Keep pressing Up to move through the history of commands you’ve typed. Pressing Down will move forward through your command history.

Second, you can see all the commands you’ve typed with the history command. Each one will be listed with a number:

 $ ​​history
  1 tree --version
  2 man echo
  3 history

You can execute any of these commands again by typing !, followed by ...

Get Small, Sharp Software Tools now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.