In my last post, I gave a brief introduction to what the terminal is, and how we use it to launch programs on our computer. We also touched a bit on the ways we can get help on how to use a given command with the Linux manual and the integrated help of each program.
Now, I want to share with you some things that will (probably) make your terminal usage a bit more pleasant, and save you some typing.
Just as last time, I’m writing this post with Bash in mind. It may however, apply to other terminal emulators as well, just so you know!
Finish the execution of something (Ctrl+C)
If you find yourself waiting too long for something to complete, or realizing you’ve mistyped something just after hitting enter, you’ll probably want to stop the current program from executing.
You can achieve this by hitting the Ctrl+C keys, which will send a signal to the program to stop its execution.
Ctrl+C and Ctrl+D
In some tutorials and examples, you may see Ctrl+D being used to stop an execution as well, however, it is worth noting that Ctrl+C and Ctrl+D have some important differences.
Ctrl+C will send a signal to stop what’s currently running, while Ctrl+D is interpreted as an “End of File” (EOF). What’s an End of File? Imagine having a key on your keyboard that basically means “I’m done entering info”, well, that’s basically what EOF means. Some programs, in some contexts, will interpret an EOF as a request to exit.
Copying and Pasting
If you’re just starting with the terminal, you might already noticed how we can’t copy and paste like everywhere else! Our famous shortcuts, Ctrl+C and Ctrl+V no longer work, and they just display ^C and ^V on the screen, with ^C also stopping our running programs.
That’s because, as mentioned earlier, entering Ctrl+C into a terminal will send a signal to stop executions, and, funnily enough, every Ctrl+Key shortcut is reserved by our terminal for its own purposes.
We can, however, still copy and paste in a terminal window, just not with our known shortcuts. A workaround is to use the mouse right-click to copy and paste, but a more “intended” solution is to use new shortcuts, Ctrl+Shift+C for copying and Ctrl+Shift+V for pasting.
Command History (↑ and ↓)
One of the first things you should know is that, in a terminal window, you can use the Up (↑) and Down (↓) arrow keys on your keyboard to navigate through your history.
Using the ↑ key on a terminal will switch the current entry line contents with the last command entered. After that, you can keep using the ↑ and ↓ keys to navigate through all the stored commands that you have previously entered. Going “up” will display older and older entries, and going “down” will go towards the most recent ones, until the entry line that we begun with.
Once you’ve reached your desired entry, you can edit it as usual (if you want to), and execute it with Enter.
Command History Search (Ctrl+R)
So, using our keyboard arrows to navigate through our history is cool and all, but, what if you want to execute something that you’ve typed long ago, without typing it again or traversing all your history?
Well, in that case, you can use “reverse-i-search” to look through your entry history in a more efficient way. To use it, hit Ctrl+R in a terminal window, and you’ll enter the search mode. There, you can type whatever you’re looking for, and the search tool will display the most recent match, if there’s any. If you’re looking for an older match, you can keep hitting Ctrl+R, which will show other matches, in reverse chronological order.

To execute the current match, you can hit Enter. To modify it before execution, you can use any of the arrow keys, which will exit the search mode, while preserving the current match on the terminal so you can edit it.
If you’re in search mode and you want to exit, you can hit Ctrl+C.
Next time, I’ll share with you some more tricks that I find really useful when working on the terminal. See you later!
Featured image by Dries Augustyns on Unsplash
Leave a Reply