How to use the command history function in Command Prompt
Command Prompt is an extremely familiar command for anyone using Windows operating system. Besides, a lot of current software also supports the command line to perform actions on the Command Prompt window, instead of on the screen.
Command Prompt has long been a familiar command execution program for Windows users. Through Command Prompt, users can enter commands to run the system from the command input interface, without having to manipulate directly on the computer screen. On the Command Prompt, there is also a history function, which helps users review the commands that have been run in previous versions. This makes it easier to check the command line you used. In the following article, we will introduce to the user the command history function on the Command Prompt and the shortcut that navigates the command history.
First of all, to open the Command Prompt, on your computer, right-click on the Start icon or press the Windows + X key combination and select Command Prompt (Admin) .
1. Shortcuts navigate the Command Prompt command history:
- Arrow key up: Execute the command you typed earlier.
- Arrow key down: Execute the command that was typed later.
- Page Up: Execute the first command in the list of command sessions.
- Page Down: Execute the last command in the list of command sessions.
- Esc: Delete the command line.
2. Function F key uses the Command Prompt command history:
1. F7 key:
Review the command history in tabular form. We use the up and down arrow keys to select the command in the history list and redo the command, if required. You press Esc to close the command history table.
2. F8 key:
You can search the command history that matches the text on the current command line. For example, to find the command that starts with "I", type "I" at the command line and press F8 to get the Command Prompt to find the history commands that begin with "I".
As shown in the figure below, look for the ipconfig command that was executed on Command Prompt.
3. F9 key:
Quickly search a command line in history based on the order in which the command was executed, in case you have executed many commands on the Command Prompt. This sequence number is displayed in the order history table when you are most F7 and start with 0.
In the picture, when pressing F9, a sequence number table will appear. When entering the number 0, the ping command is the first command used on Command Prompt.
3. Print the list of Command Prompt command history:
In case the user wants to print all the Command Prompt commands, we type the following command:
doskey / history
After executing this command, we will see the previous execution commands used in the previous version. This is the list of command history we have seen in the history command table F7.
4. How to copy the previous command in Command Prompt using keyboard shortcuts:
1. F1 key:
This key copies the first character of the previous command to remind the user of the entered command. We continue to press F1, the remaining characters of the previous command will appear.
2. F2 key:
Copy a part of the command you used earlier. We only need to enter one or several characters, the Command Prompt will search for the remaining characters of the command and automatically copy the previous command to execute the command.
The last command I used here is doskey / history. Then press F2 to appear Enter table char to copy up to then type "y". Immediately the word "doske" before the "y" character will appear for the user to enter the next command.
3. F3 key:
Copy a part of the command previously typed by the user. Command Prompt will copy from the current character position and automatically copy the rest of the previously used command starting from the character position you entered.
As shown in the picture below, I have previously used the tracert IP command on the Command Prompt. I will type "trac" and then press F3. Command Prompt will automatically complete the command for the user.
5. How to disable the Command Prompt command history:
To disable all shortcuts and navigation in the Command Prompt, we use the command line below and press the Enter key.
doskey / listsize = 0
As a result, you will not be able to use the arrow keys, F or doskey / history keys. We can still enter the command as normal but cannot manipulate the Command Prompt command history feature. However, this disabled command is only valid for each single session, in the command session then you can manipulate the same command history feature.
To delete the entire command history that was typed without turning off the Command Prompt, enter the command below and press Enter. All commands used above will disappear.
cls
6. How to save Command Prompt command history:
To save the command line history in Command Prompt to txt file, we can create a txt file right outside the screen with any name. At the session on the Command Prompt window, enter the following command and press Enter.
doskey / history> C: UsersnameDesktopcommands.txt
Where, name is the system user name.
After that, we access the above path and will see the txt file save the Command Prompt command history that was created. You just need to open the file to see the list of commands and then finish.
The above is a tutorial on how to use the command history function on Command Prompt, with navigation shortcuts to search for used command history. Hopefully with this article, we will have more tricks to use Command Prompt more effectively for use.
Refer to the following articles:
- Summary of the common Run CMD commands
- Trick to disable Command Prompt on Windows
- How to activate Ctrl + C / Ctrl + V to execute paste command in Command Prompt window?
You should read it
- How to open Command Prompt on Windows 10, 8, 7, Vista and XP
- How to use Xcopy command in Command Prompt
- Add Command Prompt to Power User Menu on Windows 10
- How to Make Command Prompt Appear at School
- Windows prompt
- Instructions for using Command Prompt
- 6 Best Command Prompt Alternatives for Windows
- How to Open Folders in CMD
- All Frequency Restart, Shutdown, Remote Off ... with Command Prompt
- How to Execute a Program in Command Prompt
- How to find and open files with Command Prompt
- How to Customize the Font in Windows Command Prompt