5 Command line tips and tricks
In this brief chapter, we’ll touch on a few things that should help you work quicker in the Terminal. We’ll also touch on navigating common issues you’ll probably run into.
5.1 Command History
The command line keeps a history of the commands you give it. Much like scrolling back up through the messages in a conversation on your phone, you can “scroll up” through the conversation you’ve had with the terminal (only with the terminal, you’ll only see the messages you sent).
How to view your command history:
To see prior commands you’ve written, just press the up arrow ↑
on your keyboard. Each press will take you to the prior command in your history.
To get back to an empty prompt, scroll back down using the down arrow ↓
You can re-run any command that pops up simply by hitting the Enter
/ return
key on your keyboard. No need to re-type things!
Why this is useful
In programming, we repeat commands quite frequently (think about how often you re-run your notebook code in R-Studio, for example).
Having a command history is helpful because it:
- Saves time – You can quickly repeat or modify previous commands with the ↑ key instead of retyping them.
- Reduces mistakes – Reusing known, valid commands lowers the chance of typos or syntax errors.
- Aids in learning – You can review what you’ve done, which helps you remember your steps and can help with troubleshooting if something goes wrong.
5.2 Canceling a Command
One of the scariest things for new command line users happens when you run something you didn’t mean to. We’ve been walking through things slowly and together in this guide, but you’ll be more on your own in the real world, and we promise you will mess up at some point.
If you realize you made a mistake while a command is running, press:
Ctrl + C
This cancels the running command and brings you back to the prompt.
5.3 Tab Completion
You read about this in chapter 2, but it’s worth mentioning again because it’s that good.
Remember: start typing a folder or file name, press Tab
, and Terminal finishes it for you if possible.
It saves time and typos!
If there’s more than one similarly-named files in your folder, you may have to type more characters to get to the one you want. You can also hit Tab
again to see a list of possible matches to help guide you.
5.4 🎯 Checkpoint
In this chapter you’ve learned:
- How to view your command history and use it to rerun prior commands.
- How to cancel a command.
- How to use tab to auto-complete file and folder names.
5.5 🎉 Final Words
Congratulations! You’ve made it to the end of the Intro to Terminal guide.
You’ve now learned:
- How to open the Terminal
- How to move around
- How to create and manage files and folders
- How to read and use simple flags
- How to fix common mistakes
You’ve built a real foundation for anything else you’ll learn later — whether that’s coding, scripting, data science, or just being more powerful with your own computer.
Remember: the terminal is your friend.
Keep practicing — the more you use it, the more natural it will feel.
If you forget how to do something or get stuck you may find the quick reference and troubleshooting appendices helpful.
Good job! 🚀
Next up:
We’ll learn how about some common command line issues and how troubleshoot when you run into them.