published on in blog

Handy Keyboard Shortcuts for the Linux Bash Terminal

The Linux Bash (Bourne Again Shell) is a shell and command language that is known to most Linux users, since it's the default shell in most Linux distributions.

A beginner Linux user may find the Linux terminal usage a bit hard to grasp, especially because it relies heavily on using your arrow keys to move around. Additionally, constantly re-typing the commands, each with a slight variation, can be annoying.

However, Bash comes with many easy-to-use keyboard shortcuts and history functions that ensure efficient use of the terminal. For making effective use of time, we have put together a list of the most commonly used Bash keyboard shortcuts.

FREE DOWNLOAD: This cheat sheet is available as a downloadable PDF from our distribution partner, TradePub. You will have to complete a short form to access it for the first time only. Download the Linux Bash Terminal Cheat Sheet.

Linux Bash Terminal Keyboard Shortcuts

ShortcutAction
Bash Navigation
Ctrl + AMove to the start of the command line
Ctrl + EMove to the end of the command line
Ctrl + FMove one character forward
Ctrl + BMove one character backward
Ctrl + XXSwitch cursor position between start of the command line and the current position
Ctrl + ] + xMoves the cursor forward to next occurrence of x
Alt + F / Esc + FMoves the cursor one word forward
Alt + B / Esc + BMoves the cursor one word backward
Alt + Ctrl + ] + xMoves cursor to the previous occurrence of x
Bash Control/Process
Ctrl + LSimilar to clear command, clears the terminal screen
Ctrl + SStops command output to the screen
Ctrl + ZSuspends current command execution and moves it to the background
Ctrl + QResumes suspended command
Ctrl + CSends SIGI signal and kills currently executing command
Ctrl + DCloses the current terminal
Bash History
Ctrl + RIncremental reverse search of bash history
Alt + PNon-incremental reverse search of bash history
Ctrl + JEnds history search at current command
Ctrl + _Undo previous command
Ctrl + P / Up arrowMoves to previous command
Ctrl + N / Down arrowMoves to next command
Ctrl + SGets the next most recent command
Ctrl + ORuns and re-enters the command found via Ctrl + S and Ctrl + R
Ctrl + GExits history search mode
!!Runs last command
!*Runs previous command except its first word
!*:pDisplays what !* substitutes
!xRuns recent command in the bash history that begins with x
!x:pDisplays the x command and adds it as the recent command in history
!$Same as OPTION+., brings forth last argument of the previous command
!^Substitutes first argument of last command in the current command
!$:pDisplays the word that !$ substitutes
^123^abcReplaces 123 with abc
!n:mRepeats argument within a range (i.e, m 2-3)
!fiRepeats latest command in history that begins with fi
!nRun nth command from the bash history
!n:pPrints the command !n executes
!n:$Repeat arguments from the last command (i.e, from argument n to $)
Bash Editing
Ctrl + UDeletes before the cursor until the start of the command
Ctrl + KDeletes after the cursor until the end of the command
Ctrl + WRemoves the command/argument before the cursor
Ctrl + DRemoves the character under the cursor
Ctrl + HRemoves character before the cursor
Alt + DRemoves from the character until the end of the word
Alt + BackspaceRemoves from the character until the start of the word
Alt + . / Esc+.Uses last argument of previous command
Alt + <Moves to the first line of the bash history
Alt + >Moves to the last line of the bash history
Esc + TSwitch between last two words before cursor
Alt + TSwitches current word with the previous
Bash Information
TABAutocompletes the command or file/directory name
~TAB TABList all Linux users
Ctrl + ICompletes the command like TAB
Alt + ?Display files/folders in the current path for help
Alt + *Display files/folders in the current path as parameter

Plenty More to Learn About Linux

The Bash shell keyboard shortcuts work around the developer's DRY (Don't Repeat Yourself) philosophy. They help make effective use of your time by improving productivity in a fast-paced work environment.

The above cheat sheet is just the tip of an iceberg. The more you begin to explore Linux terminal commands and Bash shortcuts, the easier and more interesting Linux becomes.

ncG1vNJzZmivp6x7rq3KnqysnZ%2Bbe6S7zGijoqalrXqjrdKhZK2doqK2r63LZqqhp6KpsLbA0mg%3D