Skip to main content
p. 25

2.11 Command-Line Editing

As you play with the shell, notice that you can edit the command line using the left and right arrow keys, as well as page through previous commands using the up and down arrows. This is standard on most Linux systems.

However, it’s a good idea to forget about the arrow keys and use control key combinations instead. If you learn the ones listed in Table 2-2, you’ll find that you’re better able to enter text in the many Unix programs that use these standard keystrokes.

Table 2-2: Command-Line Keystrokes

KeystrokeAction
CTRL-BMove the cursor left
CTRL-FMove the cursor right
CTRL-PView the previous command (or move the cursor up)
CTRL-NView the next command (or move the cursor down)
CTRL-AMove the cursor to the beginning of the line
CTRL-EMove the cursor to the end of the line
CTRL-WErase the preceding word
CTRL-UErase from cursor to beginning of line
CTRL-KErase from cursor to end of line
CTRL-YPaste erased text (for example, from CTRL-U)