The GNU Bash shell, an acronym for GNU Bourne-Again Shell, is a Unix shell and command-line interpreter used in most Linux distributions and macOS. It has become the de facto standard for shell scripting and is widely used by developers and system administrators.
One of my favorite reasons for using Linux and the command line in particular is learning keyboard shortcuts, which can help to improve your efficiency and speed when using the Bash shell. This article will discuss some popular keyboard shortcuts in the GNU Bash shell to help you along the way.
After some feedback from users on the r/linux subreddit, I'd like to add that these are indeed considered
Some of these shortcuts may work in other popular shells derived from bash like ksh and zsh, but you'd have to check their corresponding help/man pages to be sure.
One of my favorite reasons for using Linux and the command line in particular is learning keyboard shortcuts, which can help to improve your efficiency and speed when using the Bash shell. This article will discuss some popular keyboard shortcuts in the GNU Bash shell to help you along the way.
- Navigation Shortcuts
- Ctrl + a: Move the cursor to the beginning of the line
- Ctrl + e: Move the cursor to the end of the line
- Alt + b: Move the cursor backward one word
- Alt + f: Move the cursor forward one word
- Ctrl + xx: Toggle between the current cursor position and the beginning of the line
- Editing Shortcuts
- Ctrl + w: Cut the word before the cursor
- Alt + d: Cut the word after the cursor
- Ctrl + k: Cut the text from the cursor to the end of the line
- Ctrl + u: Cut the text from the cursor to the beginning of the line
- Ctrl + y: Paste the last cut text
- Alt + y: Paste the second most recent cut text
- Ctrl + _: Undo the last change
- Command History Shortcuts
- Ctrl + p: Show the previous command from history
- Ctrl + n: Show the next command from history
- Alt + .: Insert the last argument of the previous command
- Ctrl + r: Search the command history backward (use Ctrl + s to search forward)
- Ctrl + g: Exit command history search mode
- Ctrl + o: Execute the found command from history and show the next command
- Ctrl + l: Clear the screen (same as the 'clear' command)
- Process Control Shortcuts
- Ctrl + c: Send the SIGINT signal to the current foreground process, usually resulting in termination
- Ctrl + z: Send the SIGTSTP signal to the current foreground process, suspending its execution
- Ctrl + d: Send an EOF (End of File) to the current process, usually resulting in termination or logout
- Ctrl + s: Pause the output to the terminal (useful when scrolling through large amounts of output)
- Ctrl + q: Resume output to the terminal after pausing with Ctrl + s
- bg: Resume a suspended process in the background
- fg: Resume a suspended process in the foreground
- Miscellaneous Shortcuts
- Ctrl + t: Transpose (swap) the characters before and under the cursor
- Alt + t: Transpose (swap) the words before and under the cursor
- Alt + u: Uppercase the word from the cursor to the end of the word
- Alt + l: Lowercase the word from the cursor to the
After some feedback from users on the r/linux subreddit, I'd like to add that these are indeed considered
readline
commands/shortcuts that work while bash is in the default 'emacs' mode. These likely won't work if you're in vi
mode. For more info, type help
at your bash prompt or for even more info take a look at the bash man page by typing man bash
. Further, you could check out the readline
man page.Some of these shortcuts may work in other popular shells derived from bash like ksh and zsh, but you'd have to check their corresponding help/man pages to be sure.
Last edited: