• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Section B.1. MS-DOS Crash Course

B.1. MS-DOS Crash Course

You should know the following basic DOS commands to be able to complete the solutions in this book and get by in the world of Windows. The commands shown here are in constant width, and any parameters (the information you supply to the command) are in constant width italic. It doesn't matter which case you use when you type them in DOS (DOS, like Windows, is not case-sensitive). If there is more than one parameter, each is separated by a space:

attrib attributes filename

Changes the attributes (also called properties) of a file or folder. The four attributes are R for read only, S for system, A for archive, and H for hidden.

In Explorer, you can right-click on a file or group of files to change the attributes; attrib is the DOS counterpart to this functionality. In addition, attrib lets you change the S (system) attribute, something Explorer doesn't let you do. Here are some examples:

  • attrib +h myfile.txtthis turns on the H parameter for the file myfile.txt, making the file hidden.

  • attrib -r "another file.doc"this turns off the R (read-only) parameter for the file another file.doc (note that quotation marks are used because of the space in the filename).

  • Type attrib /? for additional options.

cd foldername

Changes the working directory to foldername. If the prompt indicates you are in C:\Windows and you want to enter the c:\Windows\Desktop folder, type cd desktop. You can also switch to any folder on your hard disk by including the full path of the folder. Type cd .. to go to the parent folder. Type cd by itself to display the current directory.

To switch to another drive, just type the drive letter, followed by a colon (:). For example, type a: to switch to the floppy drive.

copy filename destination

Copies a file to another directory or drive, specified by destination. This is the same as dragging and dropping files in Explorer, except that the keyboard is used instead of the mouse. For example, to copy the file myfile.txt (located in the current working directory) to your floppy drive, type copy myfile.txt a:\. Type copy /? for additional options.

del filename

Deletes a file. For example, to delete the file myfile.txt, type del myfile.txt. This is not exactly the same as deleting a file in Windows, because the file will not be stored in the Recycle Bin. The advantage of the DOS variant is that you can easily and quickly delete a group of files, such as all the files with the .tmp extension: del *.tmp. Type del /? for additional options.

deltree foldername

Deletes a directory and all of its contents, including all subdirectories. This, obviously, can be a dangerous command, so use it with caution. However, deleting a large number of files can often be done much faster with deltree than by using Windows. Type deltree /? for additional options.

dir name

Displays a listing of all the files and directories in the current working directory. Use cd to change to a different directory. Type dir c:\files to display the contents of C:\Files without having to first use the cd command. Type dir /p to pause the display after each page, useful for very long listings. You can also specify wildcards to filter the results; type dir *.tmp to display only files with the .tmp filename extension. Type dir /? for additional options.

edit filename

Opens the DOS counterpart of Notepad, allowing you to edit a text file. It's especially useful if Windows isn't running and there's no other choice.[1] Press the Alt key to enter the menu. You may have to use attrib first if the file is a hidden or system file.

[1] For example, if you used a Startup disk to boot directly into DOS, as described in Chapter 6.


Closes the command-prompt window. In most situations, you can just click the close button [x] on the upper-right corner of the Window, but the exit command works just as well.

MD foldername

Stands for make directory. This command creates a new directory with the name foldername. The command will have no effect if there's already a directory or file with the same name.

MOVE filename destination

Is the same as copy, except that the file is moved instead of copied. Type move /? for additional options.

RD foldername

Stands for remove directory. This command removes an existing directory with the name foldername. The command will have no effect if the directory is not empty. To remove a directory and all of its contents, use deltree.

REN oldfilename newfilename

Renames a file to newfilename. This is especially useful because you can use the ren command to rename more than one file at once—something Explorer doesn't let you do. For example, to rename hisfile.txt to herfile.txt, type ren hisfile.txt herfile.txt. To change the extensions of all the files in the current working directory from .txt to .doc, type ren *.txt *.doc. Type ren /? for additional options.

START name

Allows you to open a folder window and execute a Windows shortcut from the command prompt or from a DOS batch file. For example, start c:\windows opens c:\Windows in a new folder window.

TYPE filename

Displays the contents of a text file. Type type filename | more to display the file and pause between each page of information rather than displaying the whole file at once.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint