Skip to main content

Keyboard shortcuts for editing CLI commands

The command at the current command prompt is the active command. Using keyboard shortcuts enables you to edit the active command quickly. These keyboard shortcuts are similar to those of the UNIX tcsh shell and the Emacs editor.

The following table lists the keyboard shortcuts for editing CLI commands. Ctrl- indicates that you press and hold the Ctrl key while typing the character specified after it. Esc- indicates that you press and release the Esc key and then type the character specified after it.

If you want to…Use the following keyboard shortcut…
Move the cursor back by one characterCtrl-B
Back arrow
Move the cursor forward by one characterCtrl-F
Forward arrow
Move the cursor back by one wordEsc-B
Move the cursor forward by one wordEsc-F
Move the cursor to the beginning of the lineCtrl-A
Move the cursor to the end of the lineCtrl-E
Remove the content of the command line from the beginning of the line to the cursor, and save it in the cut buffer

The cut buffer acts like temporary memory, similar to what is called a clipboard in some programs.

Ctrl-U
Remove the content of the command line from the cursor to the end of the line, and save it in the cut bufferCtrl-K
Remove the content of the command line from the cursor to the end of the following word, and save it in the cut bufferEsc-D
Remove the word before the cursor, and save it in the cut bufferCtrl-W
Yank the content of the cut buffer, and push it into the command line at the cursorCtrl-Y
Delete the character before the cursorCtrl-H
Backspace
Delete the character where the cursor isCtrl-D
Clear the lineCtrl-C
Clear the screenCtrl-L
Replace the current content of the command line with the previous entry on the history list

With each repetition of the keyboard shortcut, the history cursor moves to the previous entry.

Ctrl-P
Esc-P
Up arrow
Replace the current content of the command line with the next entry on the history list

With each repetition of the keyboard shortcut, the history cursor moves to the next entry.

Ctrl-N
Esc-N
Down arrow
Expand a partially entered command or list valid input from the current editing positionTab
Ctrl-I
Display context-sensitive help?
Escape the special mapping for the question mark (?) character

For instance, to enter a question mark into a command's argument, press Esc and then the ? character.

Esc-?
Start TTY outputCtrl-Q
Stop TTY outputCtrl-S