A standard Bash terminal is automatically set to insert mode, so you don't have to press the Insert key to insert text. Use the up and down arrow keys to recall a previous command, and then other cursor keys to edit that line as needed.
All you need for this example is a terminal running the Bash shell. Other terminals may not have these capabilities.
We will run a few commands as follows:
Type in the command
route
and press the Enter key.Do the same for
uptime
,ls
,date
, andsync
, pressing Enter after each command.Now press the up arrow key one time. You should see the following command:
sync
Now press the up arrow two more times. You should see
date
andls
.Press Enter. The
ls
command will run again. Pressing Enter will always run the command shown.
The line is stored in a buffer with full editing capabilities. This buffer is sent to the OS when the Enter key is pressed.
The summary of the keys used for retrieval and editing is as follows:
Up arrow: It is used to scroll up the history buffer
Down arrow: It is used to scroll down the history buffer
Home: It is used to bring the cursor to the beginning of the line
End: It is used to bring the cursor to the end of the line
Delete: It is used to delete the character to the right of the cursor
Backspace: It is used to delete the character to the left of the cursor and shift the line
Left and right arrow: These are the cursor movement keys