Command-Line Editing

As you play around with the shell, you may notice that you can edit the command line with the left and right arrow keys, as well as page through previous commands with the up and down arrows. This is as good as standard on almost any Linux system.

However, you should forget about the arrow keys and use control key sequences instead. If you learn and practice the ones listed in Table 1-2, you will have a great advantage when entering text in the many Unix programs that use these standard keystrokes.

Table 1-2. Command-Line Keystrokes

Keystroke

Action

CONTROL-B

Move cursor left

CONTROL-F

Move cursor right

CONTROL-P

View previous command (or move cursor up)

CONTROL-N

View next command (or move cursor down)

CONTROL-A

Move the cursor to the ...

Get How Linux Works now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.