Terminal Shortcuts: Readline Keybindings You Need
Your Terminal Can Be Much Faster
Mistyping a command and crawling back with the arrow keys. Retyping that long command you ran a minute ago. These quietly slow moves all disappear once you learn a handful of shortcuts (keybindings).
In this guide, Lina and Linny-senpai walk through the Readline shortcuts that speed up terminal input. The same keys work in both bash and zsh.
What You'll Learn
- That these shortcuts come from a library called Readline
- How to jump to the start or end of a line instantly (Ctrl+A / Ctrl+E)
- How to delete input in bulk (Ctrl+U / Ctrl+K / Ctrl+W)
- How to search and reuse past commands with Ctrl+R
- A short cheat sheet you can start using today
1. Where Do These Shortcuts Come From?
Conclusion: Shortcuts like Ctrl+A are not bash-specific. They come from Readline, a line-editing library, so they work across many shells.
Readline is the "line editor"
Readline manages that single line of command text: entering it, editing it, recalling it from history. By default it uses Emacs-style key bindings, which is why so many shortcuts use Ctrl.
2. Jump to Line Start or End Instantly
Conclusion:
Ctrl+Ajumps to the start of the line,Ctrl+Eto the end. No more mashing arrow keys to fix the front of a long command.
sudo at the front of a long command. Ctrl+A snaps you to the start in one stroke.echo this is an example of a very long command
| Key | Action | Memory hook |
|---|---|---|
Ctrl+A |
Move to line start | Ahead (start) |
Ctrl+E |
Move to line end | End |
Ctrl+F |
One char right | Forward |
Ctrl+B |
One char left | Backward |
Alt+F |
One word right | Forward word |
Alt+B |
One word left | Backward word |
Arrow keys are fine for single characters, but learning the word-wise jumps Alt+F / Alt+B makes editing paths and options much faster.
3. How to Delete Mistakes in Bulk
Conclusion:
Ctrl+Udeletes everything before the cursor,Ctrl+Keverything after, andCtrl+Wthe previous word. You can retire the Backspace key.
| Key | Action |
|---|---|
Ctrl+U |
Delete everything before the cursor |
Ctrl+K |
Delete everything after the cursor |
Ctrl+W |
Delete the word before the cursor |
Ctrl+Y |
Paste back what you just deleted |
Cut and paste are a pair
Text removed with Ctrl+U / Ctrl+K / Ctrl+W is stored in a buffer called the "kill ring." Ctrl+Y (Yank) pastes it right back. Delete something by mistake? No need to panic.
4. How to Reuse a Command You Already Ran
Conclusion:
Ctrl+Rsearches your history in reverse. Type part of a keyword and recall a long past command instantly.
docker command from yesterday — do I really have to type the whole thing again?Ctrl+R, then type part of the command, like docker.(reverse-i-search)`docker': docker compose up -d --build
The Ctrl+R flow
- Press
Ctrl+R(the prompt shows(reverse-i-search)) - Type part of the command (partial matches appear)
- Press
Ctrl+Ragain for older matches Enterto run /Ctrl+Gto cancel
The up/down arrows, or Ctrl+P (Previous) / Ctrl+N (Next), step through history one command at a time. When you just want to tweak the last command, this is quicker.
5. Resetting the Screen and Your Input
Conclusion:
Ctrl+Lclears the screen,Ctrl+Cinterrupts a running command, andCtrl+Dsignals end of input. These are your escape hatches.
Ctrl+L wipes it clean. It's the same as the clear command, but faster than typing it. And if a command seems frozen and won't finish, Ctrl+C interrupts it.Ctrl+D signals "end of input." Press it on an empty prompt and you log out (the shell exits). You also use it to finish input when, say, cat is waiting for you to type.| Key | Action |
|---|---|
Ctrl+L |
Clear the screen (like clear) |
Ctrl+C |
Interrupt the running command (SIGINT) |
Ctrl+D |
End of input / exit the shell on empty prompt |
Ctrl+C and Ctrl+D do different jobs. Ctrl+C means "stop what's running now," while Ctrl+D means "I'm done typing." If something looks frozen, try Ctrl+C first.
6. The Shortcuts to Learn First
Conclusion: You don't need all of them at once. Drill just five — line start/end, line delete, and history search — and your speed changes noticeably.
| Priority | Key | Action |
|---|---|---|
| 1 | Ctrl+A |
Move to line start |
| 2 | Ctrl+E |
Move to line end |
| 3 | Ctrl+U |
Delete everything before cursor |
| 4 | Ctrl+R |
Reverse-search command history |
| 5 | Ctrl+L |
Clear the screen |
Shortcuts stick only when you use them on real commands. Try them hands-on over at How to Use the Terminal.
Summary
- These Ctrl shortcuts come from the Readline library, so they work in both bash and zsh
Ctrl+A/Ctrl+Ejump to the line start and end instantlyCtrl+U/Ctrl+K/Ctrl+Wdelete input in bulk, andCtrl+Ypastes it backCtrl+Rsearches past commands by keyword so you can reuse themCtrl+L(clear),Ctrl+C(interrupt), andCtrl+D(end input) are good to know- Start with just five, and learn by using them