How to View Command Prompt (CMD) History

Do you want to check the CMD history of executed commands? Check this tutorial about how to view the Command Prompt history.

Command Prompt or CMD is a tool that Microsoft has been offering for a long time in its Windows operating system. Although there are many users who try to avoid the use of the CMD, every day, they are more what they dare to face with the command line.

And it is a tool that allows you to perform specific tasks that you can not do from the graphical interface of Windows. Whether you are one of those who regularly use the command prompt or if you are starting to use the CMD, I’m going to show you a little trick to easily see the last commands used in the command prompt.

Since the command prompt or CMD is a command-based tool, one of the most useful functions when using it is to know how you can view the history of commands used in the same session.

Method #1: Command Prompt History

If you want to see the list of all the commands used in the command prompt you can use this simple command:

doskey /history

The result will be something like this:

command prompt history

Now I will show you some keyboard keys that will help you with the Command Prompt history.

– It allows you to visualize the last command executed, you can continue pressing it to see the previous commands made.

– You can use this key to go back to the last command executed, works together with the up key.

Page Down – This command helps you to get the first command used in the current command prompt session.

Page Up – It allows you to retrieve the most recent command of the current session

Esc – Clear the command line

In the same way, some function keys allow you to execute specific actions in the command prompt such as:

F7 – This option will enable you to see the command history in a pop-up window where you can select the desired command by pressing the arrow keys is an alternative to doskey.

f7 history

F8 – It allows you to search in all the command history, a command that complies with the current condition, for example, you can enter the letter C in the command line and press F8 to display all the commands that start with that letter. You can press this key next to see all the options.

F9 – It allows you to recover a command stored in history by indicating its number in the history buffer. You will see these numbers in a pop-up window and next time to access in a more agile way, use the F9 key and the respective number.

Method #2: Clean Command Prompt History

The most practical method to erase the command history in the command prompt is closing the window since in Linux systems remember the history is still valid even after closing the terminal.

You can execute the following command so that the command prompt in Windows does not remember any command:

doskey /listsize=0

Using this option, you will not be able to run the functions of the F7 key or the doskey /history command, but this will only be active during the current session. The cls (Clear Screen) command will be useful to erase the command history without closing the active window, as long as you have executed the command doskey /listsize=0 beforehand.

Method #3: Export Command Prompt History

It is possible that at some point, you want to back up the history of commands executed at the command prompt by some administrative or control task.

For this, you can use the command doskey and a defined path to store these commands. The syntax to use will be as follows.

doskey /history > C:\users\User\Desktop\commands.txt

The character > redirects the result to the indicated route. Now you go to the indicated path and open the file that you have created:

cmd history

Wrapping Up: CMD History

In this way, you can get the command prompt history in Windows environments in a useful and straightforward way. You only need to follow these simple steps to do it. Have you been able to see your CMD history? Let me know in the comments section.

Must Read:

Rating: 5.0/5. From 1 vote.
Please wait...

Leave a Reply

Your email address will not be published. Required fields are marked *