How to use the command history function in Command Prompt

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) .

How to use the command history function in Command Prompt Picture 1

1. Shortcuts navigate the Command Prompt command history:

  1. Arrow key up: Execute the command you typed earlier.
  2. Arrow key down: Execute the command that was typed later.
  3. Page Up: Execute the first command in the list of command sessions.
  4. Page Down: Execute the last command in the list of command sessions.
  5. 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.

How to use the command history function in Command Prompt Picture 2

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.

How to use the command history function in Command Prompt Picture 3

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.

How to use the command history function in Command Prompt Picture 4

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.

How to use the command history function in Command Prompt Picture 5

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.

How to use the command history function in Command Prompt Picture 6

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.

How to use the command history function in Command Prompt Picture 7

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.

How to use the command history function in Command Prompt Picture 8

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.

How to use the command history function in Command Prompt Picture 9

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

How to use the command history function in Command Prompt Picture 10

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.

How to use the command history function in Command Prompt Picture 11

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.

How to use the command history function in Command Prompt Picture 12

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:

  1. Summary of the common Run CMD commands
  1. Trick to disable Command Prompt on Windows
  1. How to activate Ctrl + C / Ctrl + V to execute paste command in Command Prompt window?
4 ★ | 3 Vote

May be interested

  • Windows promptWindows prompt
    the prompt command changes the command prompt cmd.exe file.
  • How to Customize the Font in Windows Command PromptHow to Customize the Font in Windows Command Prompt
    many people work regularly with the windows command prompt. one of the main problems users encounter, however, is the difficulty of achieving the same look every time one works with the command prompt interface. this article is intended to...
  • How to Unblock Command Prompt AnywhereHow to Unblock Command Prompt Anywhere
    have you ever been at school and discovered that the it administrators blocked the command prompt? or did you try to do a command and it says 'access is denied'? this article will explain how to bypass these restrictions using simple...
  • How to Create a Custom Windows Command PromptHow to Create a Custom Windows Command Prompt
    the windows command prompt (located at c:windowssystem32cmd.exe) is a useful tool to perform various administrative tasks. the prompt is a string of characters (special and non special) that are displayed whenever the command prompt is...
  • How to Change Directory in Command PromptHow to Change Directory in Command Prompt
    this article shows you how to change folders in the command prompt program on a windows computer. to change commands in command prompt, you must use an administrator account.
  • The most complete and easy way to use CMD (Command Prompt)The most complete and easy way to use CMD (Command Prompt)
    instructions on how to use the cmd command line tool cmd (command prompt) from a to z. the most basic knowledge about the cmd tool that you need to know
  • How to Execute a Program in Command PromptHow to Execute a Program in Command Prompt
    this article shows you how to open a program on a windows computer using the command prompt application. although you can only open programs that are installed in folders created by windows (such as desktop), you are still allowed to add the program's folder to the command prompt list to open the program with the command prompt.
  • How to Watch Star Wars on Command PromptHow to Watch Star Wars on Command Prompt
    this wikihow teaches you how to watch a version of 'star wars' rendered entirely in ascii characters (by folks with a lot of free time) using command prompt on windows or terminal on mac. open command prompt. you can open command prompt by...
  • How to open Microsoft Excel from Command PromptHow to open Microsoft Excel from Command Prompt
    there are many ways to start excel using the command prompt. normally, to open a program on windows 10, most people will choose to double-click that program icon on the desktop. the case of microsoft excel is no exception.
  • How to Open Folders in CMDHow to Open Folders in CMD
    do you need to access something from the command prompt or the windows command prompt? although it looks classic, this program is really easy to use if you know some basic commands. today's tipsmake will show you how to use the 'cd' command to open a folder in windows command prompt. besides, you will also know more great tips to instantly open command prompt in any folder on windows file explorer.