Home > Software Development > Tip For Tech Bloggers: Easy Way to Document Command History

Tip For Tech Bloggers: Easy Way to Document Command History

While writing technical blogs, it’s always nice to include commands and scripts that readers can try on their own. I find it a bit challenging to accurately document these in steps while intensively testing or debugging something by myself.

There are actually commands that faithfully list all the commands you typed. You can then clean them up for your posts. In the following, I introduce how to do these on Linux, Windows.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure



If you familiar with Linux, you can simply type in the following command:

$ history

You will see all the commands you ran before on the console. You can also save them into a file with Linux pipeline. With the saved file, you can download it and edit it.

$ history > history.txt

Note that the history is per user base. If you switch user and type more commands there, these commands would not be included in the current shell command after you return. You can either save them before you exiting the other shell or returning back again.

For more information on the history command, you can type in “-h” like other command for help.

Here is a nice article with deeper discussion on the history command combined with other settings, for example, find out what time the commands were executed.


On windows, you can use the doskey command like the following:

> doskey /history > history.txt

If you want to append the historical commands to an existing file, you can do this:

> doskey /history >> \history.txt

If you need help, you can type in

> doskey /?

Note that the history is per session and not persistent, meaning you will lose the history after you close the DOS window. Make sure you constantly run the doskey command to minimize the risk of accidental closing.

Here is a page with more details from Microsoft.


I know there should be a section for Mac, but I don’t use Mac these days. If you know how to do it, please feel free to leave a comment. Thanks!

Categories: Software Development Tags: ,
  1. June 10th, 2013 at 00:41 | #1

    Tip For Tech Bloggers: Easy Way to Document Command History (DoubleCloud) http://t.co/RvIycgP3sY

  1. No trackbacks yet.