Bash Shortcuts I Use Every Day

Bash - The Bourne-Again Shell

GNU Bash is a popular command-line shell used by many Linux and macOS users. It lets you execute commands, run scripts, and interact with the system. But typing commands in bash can be tedious, especially if you repeat them often or make small changes. Bash provides keyboard shortcuts that help you save time and improve your command-line experience.

These are the shortcuts I use most often for navigation, editing, control, and history.

Navigation shortcuts let you move the cursor around the current line while typing a command. They help you quickly reach the beginning or end of the line, move forward or backward by one character or one word, or switch between different positions.

commanddescription
ctrl + aMove to the start of the command line
ctrl + eMove to the end of the command line
ctrl + bMove one character to the left
ctrl + fMove one character to the right
alt + fMove one word to the right
alt + bMove one word to the left
ctrl + xxSwitch between the current and the first position of the cursor

Editing Shortcuts

Editing shortcuts let you modify the command you're typing. They help you delete, undo, cut, paste, complete, or capitalize characters, words, or lines.

ShortcutDescription
ctrl + x,eEdit command in editor
ctrl + dDelete a character forward or exit the shell if the line is empty.
ctrl + hDelete a character to the left. Equivalent to backspace
alt + dDelete a word forward from the cursor.
ctrl + wDelete a word backward from the cursor. Equivalent to alt + backspace
ctrl + uCut from cursor to start of line.
ctrl + kCut from cursor to end of line.
ctrl + yPaste the last cut text.
alt + uCapitalize every character from cursor to end of word.
alt + lLowercase every character from cursor to end of word.
alt + cCapitalize the character under cursor and move to end of word.
alt + tSwap current word with the previous word.
tabComplete the current word or list possible completions.

Control Shortcuts

Control shortcuts let you manage the processes running in bash. They help you stop, resume, kill, or exit processes.

ShortcutDescription
ctrl + cInterrupt (kill) the current foreground process running in bash. Sends the SIGINT signal to the process, requesting termination.
ctrl + zSuspend (pause) the current foreground process running in bash. Sends the SIGTSTP signal to the process. To resume the process later, use fg process_name command.
ctrl + sStop all output to the screen. Useful for halting verbose commands without stopping the command itself (unlike Ctrl+C).
ctrl + qResume output to the screen after stopping it with Ctrl+S.
ctrl + lClear the screen. Equivalent to running the clear command.
ctrl + dClose the bash shell by sending an EOF (End-of-file) marker to bash, prompting exit. Similar to running the exit command.

History Shortcuts

History shortcuts let you access and reuse previous commands you've typed in bash. They help you search, recall, edit, or run commands from your history.

ShortcutDescription
ctrl + rIncremental reverse search of bash history. Type a part of a command to display the most recent matching command. Press Ctrl+R again for older matching commands. Press Enter to run or Esc to edit before running.
ctrl + sIncremental forward search of bash history. Similar to Ctrl+R but searches forward.
alt + pNon-incremental reverse search of bash history. Type a part of a command and press Alt+P to see older matching commands. Press Enter to run or Esc to edit before running.
alt + nNon-incremental forward search of bash history. Similar to Alt+P but searches forward.
ctrl + p or up arrowMove to the previous command in history.
ctrl + n or down arrowMove to the next command in history.
ctrl + oRun the current command and re-enter it in history.
ctrl + gExit the history search mode without running the command.
!!Run the last command in history.
!*Run the last command in history except its first word.
!:pDisplay what ! substitutes.
!xRun the most recent command in history that begins with x.
!x:pDisplay the x command and add it as the most recent command in history.
!$Substitute the last argument of the previous command in the current command.
!^Substitute the first argument of the previous command in the current command.
^123^abcReplace 123 with abc in the previous command and run it.

Bash keyboard shortcuts are powerful tools that can improve your productivity when working with the command-line shell. I use these shortcuts daily and they've become second nature. Here's hoping they help you work faster too.

ResourceLink
GNU Bashhttps://www.gnu.org/software/bash/
GNU Bash Manualhttps://www.gnu.org/software/bash/manual/bash.html
About the Author

Asaduzzaman Pavel

Software Engineer who actually enjoys the friction of well-architected systems. 15+ years building high-performance backends and infrastructure that handles real-world chaos at scale.

Open to new opportunities

Comments

  • Sign in with GitHub to comment
  • Keep it respectful and on-topic
  • No spam or self-promotion