You are on page 1of 5

Basic DOS Commands

Overview
This document is an introduction to DOS concepts, vocabulary, and the most frequently used
commands.
What is DOS?
DOS stands for Disk Operating System - an operating system gets your computer running and
controls the operation of your computer's activities. DOS manages the flow of information to and
from the various parts of your computer system.
To work with DOS it is necessary to choose commands which direct your system to perform
specific tasks. DOS includes commands which direct your system to perform tasks like moving
files from one disk to another, copying files and backing up existing files (backing up a file
means making another copy of an existing file just in case anything should happen to the
original. This is a practice we highly recommend).
The DOS prompt
The DOS prompt is where you type commands. The command prompt will be a drive letter
followed by a colon and a backslash. (A:\ for example) or a backslash followed by the name of a
directory(A:\MYNAME for example). The letter indicates which disk drive is the current drive,
DOS searches the current drive for the information it needs to process the commands you type.
To direct DOS to perform a task, you type a command and then press Enter.
NOTE: DOS is not case sensitive; therefore, a command can be entered in with CAPITAL
LETTERS, lower-case letters, or a MiXtuRe of the two.
Knowing the file extension:
There are many types of file now-a-days created by many package software with their identical
extension. Here I mention some familiar file format:
.sys
.com
.exe
.ini
.bat
.cab
.cat
.inf
.txt

system
command
executable
initialization
batch
cabinet file (installer)
security catalog
information
text

.doc
.xls
.mdb
.dbf
.pps
.htm
.jpg
.mpeg
.mp3

word document
excel worksheet
access database
foxpro database
power point slide show
hyper text markup language
joint picture group image
motion picture enhanced group

music play compressed class 3

Basic DOS Commands:


Check the Date and Time
DOS will let you check or change the date and time once it has been set. The procedure to do this
is as follows:
1. Type: date and press enter
2. If the correct date is displayed, simply press enter. If the date is incorrect, type the correct date
and press enter.
3. Type: time and press enter.
4. If the correct time is displayed, simply press enter. If the time is incorrect, type the correct
time and press enter.
Engr. Abdul Kadar Muhammad Masum/ Assist.Prof.of IT/ DBA/ IIUC. Page number - 1

Directory Command
The DIRECTORY command is like a table of contents in a book. This directory will list the
following information:

Filenames
File extensions
Size of each file
Date and time the file was last updated.

C:\> type: dir and press enter.


We can also use
C:\> type: dir/p and press enter. (Pause a Directory Listing)
NOTE: At the end of the listing, there is a line that shows the number of bytes free on the hard
drive.
Recall a DOS Command
The F3 function key can be used to recall the last DOS command you typed in. If you would like
to retrieve a previously entered command, you can also press the up arrow key continuously
until you reach the desired command you were looking for.
NOTE: You can also type out each letter in your last command by using the right arrow key or
the right cursor key. After you use the F3 key to recall a command, you can use the backspace
key to edit any part of the command or add to your command.
Check for a Single File
1. Make sure that you are at your C:\> prompt.
2. Type: dir file_name.extention (filename.extension) and press enter.
3. The screen will display a listing of the file or a file not found message.
Check for a Group of Files
1. Type: dir c* and press enter.
2. All filenames that begin with the letter C will be listed.
List Files with the Same Extensions
1. Type: dir *.bat and press enter.
2. All files with the .bat extension are listed.
View all files of a subdirectory
1. C:\>Type CD Subdirectory press Enter.
2. C:\subdirectory> type dir press enter.
Or
C:\>Type dir \subdirectory press Enter.
Clear the Screen
When the screen get full of information, you may want to clear it. To do this, type CLS at the
C:\> prompt and press enter.
Create a Subdirectory
To create a subdirectory, you will need to use the MAKE DIRECTORY command, a.k.a. MD.
The MD command is useful for organizing files on your hard drive. With subdirectories, you can
Engr. Abdul Kadar Muhammad Masum/ Assist.Prof.of IT/ DBA/ IIUC. Page number - 2

create and store related files together. For example, one subdirectory could be used to store all
word processing files and another for all spreadsheet files.
1. Type: md info(any folder name) and press enter.
Move to the Parent Directory
DOS has a quick way to move from the current directory back to the parent directory.
1. Type: cd.. and press enter.
2. You will return back to the C:\> prompt
Move to a Subdirectory
Once you have created a subdirectory, to move to that directory, you will use the CHANGE
DIRECTORY command, a.k.a. CD.
1. Type: cd info(Sub directory name where u want to move) and press enter.
Move to the Parent Directory
DOS has a quick way to move from the current directory back to the parent directory.
1. Type: cd.. and press enter.
Move to Drive
1. Type: cd\ and press enter.
2. You will return back to the C:\> prompt.
List Subdirectories
1. Type: dir \*. and press enter.
2. All the subdirectories are listed.
NOTE: The backslash character \ directs DOS to read from the root directory. The *. requests
the listing of the subdirectories.
Copy a File into a Subdirectory
The COPY command lets you copy files from one directory to another.
1. Type: copy sales.bob info(sub directory) and press enter.
2. Type: dir info and press enter.
Copy a Group of Files into a Subdirectory from another subdirectory
When copying a group of files from the root directory into a subdirectory, it is necessary to use
the wildcard character * along with the COPY command.
1. Type: copy subdirectory(source) subdirectory(destination) and press enter.
2. All files should be listed in the destination subdirectory.
Copy same group of Files into a Subdirectory from another subdirectory
When copying a group of files from the root directory into a subdirectory, it is necessary to use
the wildcard character * along with the COPY command.
1. Type: copy *extension (source) subdirectory(destination) and press enter.
2. All files should be listed in the destination subdirectory.
Copy all Files in a Subdirectory or drive
1.Enter into a directory or subdirectory
2.C:\Type:copy *.* d: (destination) and press enter.
Copying all directory and subdirectory to destination
1. c:\> type XCOPY [source] [destination] [/E |
Engr. Abdul Kadar Muhammad Masum/ Assist.Prof.of IT/ DBA/ IIUC. Page number - 3

Continues copying even if errors occur.


1:\> type XCOPY [source] [destination] [/C|
Rename a File
The RENAME command lets you rename a previous file with a new name.
1. Type: ren quick2.ltr sales.ltr and press enter.
Rename a Group of Files
With the wildcard character *, you can also use the RENAME command to change a group of
files.
1. Type: ren *.ltr *.bob and press enter.
NOTE: You can also rename a group of files that have the same name but different extensions.
Type the RENAME command then the filename followed by the dot and the wildcard, space and
then type the new filename followed by a dot and the wildcard character. It will look like this:
filename.* newfilename.*
Delete a Single File or folder
1. Type: del aaaa (file name with extension )
or
2. Type: del aaaa (folder name )
3. The prompt shows you that - c:\aaa\.*, Are you sure (Y/N)?
for this we will press y
Delete same group of Files from a directory
When deleting a group of files from the root directory. You have to enter into that directory first
and it is necessary to use the wildcard character * along with the DEL command.
1. Type: del *extension (file type say they are doc) and press enter.
Delete all Files in a Subdirectory
1.Enter into a directory or subdirectory
2.Type: del *.* and press enter.
There are two rules you will need to follow before removing a subdirectory.
RULE 1: All files in the subdirectory must be deleted.
NOTE: Never type DEL *.* when you are in the root directory. It will destroy all DOS files
that are necessary to boot and operate the computer.
EXAMPLES of DELETE Command
Notice: Users who are running Microsoft Windows and are used to deleted items going to the
recycle bin need to keep in mind that deleting files from MS-DOS does not send files to the
recycle bin.
del test.tmp = Deletes the test.tmp in the directory that you currently are in, if the file exists.
del c:\windows\test.tmp = Delete the c:\windows\test.tmp in the windows directory if it exists.
del c:\windows\temp\*.* = (* is for wild character(s)) *.* indicates that you would like to delete
all files in the c:\windows\temp directory.
Color the dos prompt and text
Sets the default console foreground and background colors.
1. c:\ Type COLOR [attr]
attr
Specifies color attribute of console output
Engr. Abdul Kadar Muhammad Masum/ Assist.Prof.of IT/ DBA/ IIUC. Page number - 4

Color attributes are specified by TWO hex digits -- the first corresponds to the background; the
second the foreground. Each digit can be any of the below values.
0 = Black
8 = Gray
1 = Blue
9 = Light Blue
2 = Green
A = Light Green
3 = Aqua
B = Light Aqua
4 = Red
C = Light Red
5 = Purple
D = Light Purple
6 = Yellow
E = Light Yellow
7 = White
F = Bright White
Converts FAT volumes to NTFS.
CONVERT volume /FS:NTFS [/V]
volume Specifies the drive letter (followed by a colon), mount point, or volume name.
/FS:NTFS Specifies that the volume to be converted to NTFS.
/V
Specifies that Convert should be run in verbose mode.
EXAMPLES
C: Type convert d: /fs:ntfs
i.e. Convert the d: drive, which in this example is a FAT volume, to a NTFS volume. Note, if this
volume is anything other than FAT, such as NTFS or RAW, this command will generate an
error.
Exploring a file
1. d:\> type file-name.extension and press enter
Close the DOS
1. c:\ type exit and press enter
Some important commands:
C:\ type Shutdown -l and press enter
The command is used to log off the computer user account.
C:\ type Shutdown -r and press enter
The command is used to restart the computer.
C:\ type Shutdown -s and press enter
The command is used to shutdown the computer.
C:\ type Shutdown -f and press enter
The command is used to shutdown the computer by enforcing.

Engr. Abdul Kadar Muhammad Masum/ Assist.Prof.of IT/ DBA/ IIUC. Page number - 5

You might also like