You are invited to Log in or Register a free Frihost Account!

In Command: The Windows Command Prompt

In Command: The Windows Command Prompt

A lot of (recurring) administrative tasks can be handled by the right use of the commandline interface. Although this is common knowledge among Linux users, most Windows users seem to ignore the command prompt. This is too bad, because using the commandline at the right time, for the right job, can save you a lot of work and time. Not despite its lack of a nice graphical user interface, but because you are not hindered by a bloated, shiny interface.

But to maximize the profit of the commandline, it pays off to take a little time to get prepared first.

The Command Prompt

The commandline interface in Windows is called the Command Prompt. It is located in the Start menu, under Accessoires. Lets first create a shortcut to the Command Prompt. Right click on the Command Prompt-menu item and choose Send to->Desktop. Now, go to the desktop, right click on the newly created shortcut and choose Properties. Now you can change some properties of the commandline interface.

You can change the font (in the Font tab), the cursor size (Options tab), some colors (Colors tab) and the window size (Layout tab) among other things. I suggest you make these two changes:

Equipping Your Toolbox (Windows)

Linux has a large set of handy tools and commands for use on the command line. These enable you perform all kinds of tasks quickly. Unfortunately, the Windows command line interface only comes with some basic tools and commands, like DIR, SORT, TYPE, etc.

Luckily for the Windows-using Power User a lot of these Linux tools have been ported to Windows. Some of these tools are great to have in your toolbox and can greatly enhance the commandline interface.

Lets take file as an example. The file command can tell the type of almost any kind of file. This is great if you encounter a file and you don't know what to do with it, especially when the extension doesn't give you a clue. First we have to install it:

Installing the GNU tools

The tools can be downloaded and installed from For example, to install the file tool, go to the list of available tools at Scroll down until you see the line containing the 'File' package, and click 'Setup' on the right of it. Download and execute the file. A setup wizard guides you through the setup.

When prompted for the directory to install in, choose a generic name, for example 'tools', or 'gnu'. If you install more tools you can put them all in the same directory. This way you have only one directory to add to your PATH later on. You can choose 'Full installation', or select only the binaries.

After installing file you have to add its directory to your PATH. This way Windows knows where to find the file command, without you having to specify the folder:Changing the path to include the new directory:

If you want to install additional tools later on, you can install them into the same directory (ie. c:\tools or c:\gnu). You don't have to change the path-variable again when you install additional tools, as long as you install them to the same directory.

Open a new Command Prompt and type 'file'. If everything is oke, the file command is found and a short help message is displayed, starting with "Usage:". Lets see if it works. Go to a random directory on your harddisk, use "dir" to see which files it contains, and choose a random file. Now type "file <filename>" and press enter. You will see something like this:


Usage: file [-bciknNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
       file -C -m magicfiles

C:\WINDOWS>file explorer.scf
explorer.scf; ASCII text, with CRLF line terminators

C:\WINDOWS>file clock.avi
clock.avi; RIFF (little-endian) data, AVI, 321 x 321, 1.00 fps, video: RLE 8bpp, audio: (mono, 8000 Hz)

C:\WINDOWS>file Zapotec.bmp
Zapotec.bmp; PC bitmap data, Windows 3.x format, 96 x 96 x 8


Great. There are a lot of tools at which are usefull to enhance your work at the commandline. I will introduce you to some of them in my In Command blogs.

Some Tips

Here are some tips to maximize your comfort when working with the Command Prompt:
  • After you typed the first few characters of a filename, hit the TAB key. The filename will be auto-completed. The first file in the current directory which has the same first characters is used. If this isn't the file you want, press TAB again, and the next file is picked. You can keep on pressing TAB until the right file is choosen.
  • Use the up and down keys to scroll through your command history. By pressing up once, you can repeat the last command you executed. Or use F7 to display the command history, select a previous command and execute it again by hitting ENTER.
  • When using a filename with spaces in it, put the name between double quotes, or else you will get an error message:

    C:>cd "Program Files"\"Mozilla Firefox"
    C:>cd "Program Files\Mozilla Firefox"

    When you use TAB, the double quotes are automatically added when necessary.
  • When you issue a command which produces a lot of output to the screen you can scroll up to read all the output. You can also append "| more" to the command:

    C:>dir \windows | more

    The output will be printed page for page, waiting for you to press a key after each page.
  • When you want help on a DOS command, or see what options it has, type HELP <command>.
  • To quickly switch between different directories, use the PUSHD and POPD commands. When you type PUSHD \windows you go to the windows directory, but the current directory is remembered. When you type POPD you are transfered back to the current directory. This also works with more directories. The directories are remembered in a stack-like fashion: First in, First out:

    C:\WINDOWS>pushd \

    C:\>pushd "Program Files\Microsoft Office"

    C:\Program Files\Microsoft Office>popd



  • To use easy copy/pasting inside the Command Prompt window and between the Command Prompt and other applications, enable the quick-edit mode. See "The Command Prompt" above for instructions.
  • Maximize the Command Prompt window using the standard maximize icon in the upper right.

1 blog comments below

Very Happy thank for tips
meaya on Tue Oct 16, 2007 11:11 pm

© 2005-2011 Frihost, forums powered by phpBB.