![]() | Command history Most shells will maintain a history of the commands you execute while you are working on the system. The system maintains this list of commands from one login session to the next by storing them in a history file located in your home directory. There are a few different methods for retrieving the commands recorded in this file. Typing the history command by itself will display a list of the last 16 commands you used. When this list is displayed, there will be a number to the left of each command. This number can be used with the r (recall) command to recall a specific command without having to type it in again. To recall the command next to number 5, you would type the following and press enter on your keyboard: $ r 5 Pressing Enter will display the selected command and re-run it for you. A more useful method for displaying previously executed commands is to search the history file for the last use of a particular command. This can be accomplished by typing the history command followed by the command you would like to find: $ history date Once the command is found and displayed, you can use the r command along with the command's number to re-run the command. |
| * You are viewing a page from LiveFire Labs' sample online UNIX training course. Click here if you do not see a blue and green frame around this page, or view the detailed description for this course. LiveFire Labs - Online UNIX Training |