Quick Links
Summary
Typing commands in a Linux terminal window can be slow and error-prone. Use these keyboard shortcuts and other command-line tricks to improve your efficiency and accuracy, and avoid frustrations and mistakes.
How These Shortcuts Can Help
The Linux command line gives you a tremendous amount of power. You get unparalleled access to the inner workings of your Linux installation. All the Linux commands, configuration files, and other tools are at your disposal. But the defining characteristic of the command line is also its biggest drawback: commands must be typed.
Typing is relatively slow. It’s also easy to make typos, especially when you’re typing unusual words such ascifsiostat. There’s a danger attached to mistyping things on computers, andLinux is no different.

But, even if your typo didn’t cause a loss of data or some other dramatic outcome, the repetition and annoyance brought about by controlling your computer through the medium of the typed word can sap your enthusiasm for what you’re trying to do.
These hints, tips, and tricks will improve your accuracy, and give a speed boost to your workflow.

Searching Your Command History
Most people know that to repeat a command you may use thecommand history feature of your shell. All the commands you’ve issued are stored in a list. The history command shows you the list. To replay a command, type an exclamation point ‘!’ followed immediately by the command number, then press Enter.
We’ll show the history list, then replay command number six.
You can also use the UpArrow and DownArrow keys to cycle through the commands in the history list. When you see the command you want to run, hit Enter.
With a very long history list, it’s faster and easier to use Ctrl+R to search through your command history.

Press Ctrl+R to start the search, then type a few characters of the command you wish to repeat. The most recently executed matching command is displayed.
In this example, I hit the Ctrl+R combination then typed “ls “, that is “ls” followed by a space.

The characters you type are displayed before the colon “:” so you can see your search clue. You can continue to type characters to refine your search, or press Enter to execute the displayed command.
Esc backs out without executing the command. This is a good way to get the command on the command line so you can edit it.

Quick Command Line Edits
You probably already know theHome, End, LeftArrow, and RightArrow keysmove the cursor through the text on the command line. Ctrl+Left Arrow and Ctrl+Right Arrow hops the cursor from word to word.
The Backspace and Delete keys erase text one character at a time, but there are faster ways to remove chunks of the command line you don’t need.

Cut and Paste on the Command Line
If you want to interact with the system clipboard on the command line, you can do so using keyboard shortcuts. They’re similar to the well-known Ctrl+C, Ctrl+V shortcuts, but you need to use shift at the same time.
Powering Up cd
Using the command line means moving around in your file system. The cd commandmoves you to another directory. There are also handy shortcuts that will take you back to your home directory.
cd ~, andcdon its own, jump back to your home directory from wherever you are in the file system.

That’s neat enough, but I findcd -more useful. cd, with the ‘-’ option, takes you back to yourpreviousdirectory. You can use it repeatedly to hop back and forth between two directories.
The name of the directory you’re returning to is printed in the terminal window.

Tab Completion
You get a serious speed and accuracy boost when you useTab completion. It removes the possibility of typing errors altogether when you’re working with filenames, directory paths, and other system values.
The technique is the same in all cases. You type a small part of the directory path, then hit Tab. The shell tries to complete the rest of the filename, directory path, or command.
If there are several possible matches, you’ll hear a bleep. Press Tab again and you’ll see the possible matches. You have to type enough characters to get past the point of ambiguity.
Here’s an example. I typed “cd Do” and hit Tab. I heard a beep, so I pressed Tab again.
Bash lists the matching directories, then restores my half-completed command line. In this case, to differentiate between the two directory names, I need only type the next letter. An “n” or a “w” will positively identify the directory I mean.
I typed “w” because I’m going to go to the Downloads directory.
When I press Tab, the rest of the directory name is added for me.
If I wanted to go to a subdirectory, I could start typing its name and hit Tab again. You can keep doing that to quickly get to deeply nested subdirectories.
You can use this technique to complete shell commands, application names, and even your own aliases and shell functions. This is a fast way to add directory path names to commands as parameters, too.
Some Other Useful Tricks
These last few are pretty well-known but, just in case they’re new to someone, these are quite possibly my most commonly used keyboard shortcuts.
Faster Is Better
The command line is a massively powerful resource, yet it can leave you feeling limited because of its one-letter-at-a-time interface. Tab completion and accelerators likecd -can give you a speed boost without the loss of accuracy you get by trying to type too fast.