Page Body

Navigate the GNU/Linux Command Line With Keyboard Shortcuts

Keyboard shortcuts can help you better navigate software interfaces. The following sections define shortcuts for the GNU/Linux command line interface (CLI). Mastering these shortcuts will make you a more adept GNU/Linux user and help you efficiently accomplish your tasks.

Note: If you are not familiar with the GNU/Linux command line interface, review the Conventions page before proceeding.

Moving Around

Control+a or Home
Move to the beginning of the line.
Control+e or End
Move to the end of the line.
Move one word back.
Move one word forward.
Move one character back.
Move one character forward.
Move between the cursor position and the beginning of the line. You can use this shortcut to repeatedly move between the cursor position and the beginning of the line.

Command Editing

Cut the text from before the cursor position to the beginning of the line.
Cut the text from after the cursor position to the end of the line.
Cut the word before the cursor.
Paste the buffer contents at the cursor position.
Capitalize every character from the cursor position to the end of the current word.
Lowercase every character from the cursor position to the end of the current word.
Capitalize the character under the cursor position. The cursor will then move to the end of the current word.
Swap the current word with the previous word.
Swap the character at the cursor with the character preceding it.
Undo last key press.
Control+h or Backspace
Delete the character before the cursor.
Control+d or Delete
Delete the character under the cursor.
Delete the current word.

Screen Control

Clear the screen.
Stop output to the screen.
Resume output to the screen.

Job Control

Suspend the foreground process. From here, you can unsuspend the process by entering fg, or place it in the background by entering bg.
Kill the foreground process by sending it a SIGINT signal.
Exit the current shell by sending an End-of-file (EOF) marker to bash. This is similar to running the exit command.

Command History

Control+p or Up Arrow
Go to the previous command in the command history.
Control+n or Down Arrow
Go to the next command in the command history.
Revert the changes to a command that you have pulled from the command history.
Activate recursive search. Recalls the last command in the command history that matches the characters that you provide. Can be pressed multiple times to move backward in the command history.
Enter Control+Shift+r to move forward in the command history. Enter Escape to exit recursive search with the command that you have found placed onto the command line (but not executed).
Run a command found with recursive search and place the next command in the command history on the command line (but not execute it) afterwards.
Exit command recursive search mode without running any commands or placing any commands on the command line.

Tab Completion

Auto-complete files, directories, and binaries.
When you press the Tab key, the shell completes an incomplete input if the continuation can be uniquely identified. For the first word of a command, bash considers all executable programs. Within the rest of the command line, bash considers all files in the current or specified directory.
If several commands or files exist whose names start out equal, bash completes the name as far as possible and then acoustically signals that the command or filename may still be incomplete. Another Tab lists the remaining possibilities.

Emacs and vi Mode

By default, most GNU/Linux distributions CLIs are set to use the emacs-style keys that were previously discussed. You can confirm what settings your system is using by displaying the contents of the SHELLOPTS variable:

$ echo "${SHELLOPTS}"

If you prefer to use vi-style keys, you can do so with the set command:

$ set -o vi && echo "${SHELLOPTS}"


To learn more about the different style keys that the Bash shell supports, refer to its man page, either on the command line (man bash) or online.


Enjoyed this post?

Subscribe to the feed for the latest updates.