Computer Basics

DOS Commands

Link to Home - Jan's Illustrated Computer Literacy 101


When your pretty graphical interface breaks, you may have to go to the command line to fix it. Even within Windows, it can be faster to type a command on the Run line than to find the right icon to start a program. So a knowledge of DOS commands is not yet useless.
 
(You'll have to use your browser's Back button to return to the page that sent you here.)

DOS Interface

The user interface with the DOS operating system is very simple. You type commands line-by-line on an undecorated computer screen. All that you see to start with is a simple designation of what directory you are in, like MS-DOS iconfor the normal root directory. 

Where you type is called the command line.


What to type (Useful DOS commands):

Command / DescriptionExample

d: (for example)
Type the letter of the drive and a colon and press ENTER to change to the named drive.

C:\mydocs>d:
D:>

dir
Lists the contents of directory,
giving for each file, the filename and extension, then the file's size in bytes, then the file's date and time of creation.
Last two lines give the total number of files in this directory, the total of the file sizes, and the amount of space still free on the current drive. If the directory contains subdirectories, they will be listed, too.

 
C:\mydocs>dir
 
Volume in drive C has no label
Volume Serial Number is 0FFD-1D51
Directory of C:\mydocs
 
.<DIR>09-26-96 9:36a
..<DIR>09-26-96 936a
memotxt11010-24-97 8:45a
letter~1doc250412-31-96 7:32p
letter~2doc453401-15-9710:35a
    3 file(s)7148 bytes
    2 dir(s)37,830,656,bytes free
 

md dirname
Makes a directory nested inside the current directory. The example makes a directory inside mydocs because that is is current directory, as is shown on the command line.

 
C:\mydocs>md mydrctry

rd dirname
Removes an empty directory. Note that you can't remove a directory that is the current one. You're standing in it! Also, you'll have to delete all the documents inside the directory before you can remove the directory.

 
C:\>rd c:\mydocs\mydrctry

cd dirname
Changes to a new directory. Note the new current directory on the command line.

 
C:\windows>cd c:\mydocs\mydrctry
C:\mydocs\mydrctry>
 

del filename
Delete a file. The example deletes a file from a different drive and directory. If the file is in the current directory, you don't have to give the full path.
 

 
C:\>del d:\worddocs\letter.doc

del *.*
User WarningThis command deletes everything in the current directory. This is second only to the format command for dangerousness! DO NOT USE this command unless you are very, very sure of what directory it will be applied to! Getting in a hurry with del can lead to a whole lot of grief. The example on the right will delete ALL files from the directory mydocs. If the current directory is the root of a drive, the entire drive will be erased. Whoops!!

 

C:\mydocs>del *.*

copy pathtofile newpathtofile         Copies file named first to location named second.

 
C:\>copy c:\mydocs\mydrctry\letter~1.doc d:\worddocs
 

move filename         Moves a file to a new location.
Looks just like "copy" above except for the word "move".

ren filename newname
Renames file with first name to second name. You must include the full path to the original file if it's not in the current directory.

 
C:\>ren oldfile.exe newfile.exe
C:\>ren c:\mydocs\myletter.doc letter1.doc
 

edit filename
Brings up the DOS Edit program so you can make changes in a text file. This is a very simple text editor and won't work with regular word processing documents. It is useful, though, for editing some of the files that manage the startup of your computer. When things go wrong at a basic level, you sometimes need Edit to fix them.

 
C:\>edit c:\autoexec.bat
 

type filename
If you want to just look at a text file, this command will display it on the monitor. But if it has many lines, you'll have to be quick to press the Pause key or the top of the file will scroll out of view before you can read it.

 
C:\>type c:\autoexec.bat
 

format drive
User Warning format is the most dangerous of all, since you can erase your hard drive with it. Use it only on floppy drives A and B, or when you really, really, really know what you are doing. Don't forget- formatting a disk erases the contents!

 
C:\>format a:


User WarningUnder ANY operating system, you can get yourself into serious trouble by renaming, moving, or deleting files when you don't know exactly what you are doing.

More on DOS Commands at ComputerHope.com

Download a complete list of DOS commands: doshelp.zip or doshelp.exe

(Use your Back button to return to the page that sent you here or click on Basics to go back to the start of the Computer Basics lessons.)


Computer Basics Appendix


Teachers: Request permission to use this site with your class

Copyright © 1997-2009 Jan Smith   <jegs1@jegsworks.com>
All Rights Reserved

Icon: DownloadIcon: CDDownload lessons
Want to help?


~~  1 Cor. 10:31 ...whatever you do, do it all for the glory of God.  ~~


Last updated: 22 Jan 2008