Using command line completion and command history
You can complete commands or filenames using TAB. Command completion helps when you forget the name of a command, and saves keystrokes when you have long filenames. For example, to see the contents of a file called longfile, in your working directory, you can type the command and the first few letters of the filename, then press TAB. Bourne Again shell tries to complete the command line for you.
Mabel:~$ more lon<TAB>
The computer beeps if you do not provide bash with enough information to complete the command line. For example, you might have more than one file beginning with the letters lon. If you press TAB a second time, bash fills in as much information as possible and then waits for input. You can type more characters and then press TAB a second time or you can press TAB again to display a list of possible completions for the filename.
The shell keeps a history of commands you enter at the command line. You can reuse or change a previously entered command using the arrow keys. These commands are stored in a history file that initializes each time you log in to your user account.
To use command completion
1. At the command line, type,
<command> <file characters>
2. Press TAB. Press ENTER if bash displays the completion you want to use.
Notes
If the computer beeps when you press TAB, type more characters and press TAB again, or press TAB twice to view a list of possible completions.
Do not include the brackets in the command line text. For information about notation conventions for commands, see "Using notation conventions for Linux commands."
To use a command using command history
1. At the command line, press UP ARROW to find a previous command.
2. Press ENTER when the command line displays the command you want to use.
To change a previously used command
1. At the command line, press UP ARROW to find the command to change.
2. Press one of the following keys to locate the command characters you want to change:
LEFT ARROW to move the cursor to the left in the command
RIGHT ARROW to move the cursor to the right in the command
CTRL + A to move the cursor to the beginning of the command line
CTRL + E to move the cursor to the end of the line
3. Type the appropriate changes.
4. Press ENTER when you finish changing the command to execute it.
Note
You can use DOWN ARROW to scroll down through previously used commands that you viewed using UP ARROW.