Sie sind auf Seite 1von 11

Page 1 of 11 Chapter 2: Dos Commands

DOS COMMANDS
• Internal Commands
• External Commands

 Internal Commands

Internal Commands are those commands that are automatically loaded in the memory
when the operating system DOS is loaded into the memory (RAM). These commands are
not seen when user views the directory by using DIR Command at the dos prompt. These
commands cannot be copied, deleted & renamed. Some commonly used Dos Internal
commands are:-

CLS DIR DATE TIME VOL VER


COPY CON TYPE REN DEL MD CD
PATH COPY RD EXIT PROMPT

1) CLS (Clear the screen) :-

Syntax = C:\>CLS

The purpose of this command is to clear the displayed screen & redisplay the DOS
Prompt at the upper left corner of screen.

2) DIR (view all directory & files) :-

It displays the list of directories and files on the screen. Directories stores group of files.
Directories can be created by user. Directories can be of three types.
a) Current directory b) Sub directory c) Root directory

a) Current Directory: It is the directory in which user is working. Ex. C:\DOS>


Here Dos is the current directory.
b) Sub directory: A directory can contain other directories in it. A directory within
other directory is called sub directory. These directories are also called child
directories. By creating subdirectories user can categorize the files in better
manner.
c) Root directory: Root directory is the starting point from where all other
directories branch out. It is represented by a backslash (\). It is also called parent
directory. When the root directory becomes current directory, the command
prompt appears like C:\>. This prompt indicates that the user is in the root
directory of drive C.

C:\ AIMIT\LETTER
Drive Root AIMIT LETTER
Directory Directory Sub Directory
Page 2 of 11 Chapter 2: Dos Commands

File: A file is the primary unit of storage on the computer. A file is a collection of text
data. Different types of documents like letter, invoices, memos etc are stored in a text file
whereas databases are stored in a database file.

Syntax = C:\>DIR/switches
C:\>DIR drive name
C:\>DIR/wild card

C:\> DIR/switches

/P Pauses after each screen of information.


/W Uses wide list format.
/A Displays files with specified attributes.
D - Directories R - Read-only files
H - Hidden files A - Files ready for archiving
S - System files
/O List by files in sorted order.
Sort order
N - By name (alphabetic) S - By size (smallest first)
E - By extension (alphabetic) D - By date & time (earliest first)
G - Group directories first P - Prefix to reverse order
A - By Last Access Date (earliest first)
/S Displays files in specified directory and all subdirectories.
/4 Displays year with 4 digits.

Wild cards: It is a set of special characters that are used with some commonly used dos
commands. There are two types of wild cards.

a) Asterisk or Star (*)


b) Question mark (?)

Asterisk or Star (*):


It matches all the characters. Ex. C:\>DIR *.* will display list of all the files in directory.
C:\> DIR *.DOC will display all the files having extension .DOC.

Question mark (?): This wild card represents a single character that a group of files have
in common.

Ex. C:\> DIR ?AM.TXT will display all the text files having any first character and
remaining is given in command.
Page 3 of 11 Chapter 2: Dos Commands

C:\> DIR ???R.DBF will display all the database files having first three letter and fourth
letter is R.

3) DATE (display the date) :-

Syntax = C:\>DATE
Current date is Tue 04-23-2002
Enter new date (mm-dd-yy):

It displays the current system’s date. User can also change the current date with new date.

4) TIME (display the time) :-

Syntax = C:\>TIME
Current time is 12:23:11.31p
Enter new time:

It displays the current system’s time. User can also change the current time with new
time.

5) VOL (display the name or volume label of disk) :-

Syntax = C:\>VOL C:

The purpose of this command is to display the volume label or name of the disk. The
length of the name of disk does not exceed 11 characters.

6) VER (display the version of DOS) :-

Syntax = C:\>VER
Windows 98 [Version 4.10.2222]

It displays the version of Dos being currently used.

7) COPY CON (create file) :-

Syntax = C:\>COPY CON <filename.Ext>

[In syntax
• Extension (Ext) is optional.
• Filename can be maximum of :-
o 8 char in DOS
o 286 char in WINDOWS

• Extension can be maximum of :-


o 3 char in DOS
o 4 char in WINDOWS
Page 4 of 11 Chapter 2: Dos Commands

• Character allowed in filename are :-


o A-Z , a-z, 0-9
o &, ^, (, ), %, $, #, @, and many more
• Character not allowed in filename are :-
o *, ?, ., space ]

It is used to create new file. The file created by this command can not be modified. If user
tries to modify the contents of the file using Copy con, it will display the message “File
already exists. Overwrite it (Y/N)?”

Syntax: C:\> COPY <file name>


To save the contents of the file either press function key F6 or Ctrl-Z (^Z) key
combinations at the last line of file. File name should not be greater than 11 characters
out of which 8 characters are for file name and 3 characters for the extension. Extension
is optional here.

Syntax: C:\> COPY CON TRY.DOC


I am using command copy con.
^Z
1 file(s) Copied
C :\>

8) TYPE (open file) :-

Syntax = C:\>TYPE <filename.Ext>


Syntax: C:\> TYPE TRY.DOC
It will display message
I am using command copy con.

It is used to view the contents of the file. This only displays the information in the file. If
it is longer than the screen, it scrolls upward till the last line of the file is displayed. The
contents of the files move upward so rapidly that it is difficult to read it. However user
can pause the movement of scrolling by pressing Ctrl-S keys of Pause key button from
keyboard.

9) REN (rename the file or directory) :-

Syntax = C:\>REN <old filename.Ext> <new filename.Ext>


Syntax = C:\>REN <old name> <new name> *for directory*
Or C:\> REN RAJ MOHAN
It renames a RAJ file, which already exists with a new name MOHAN.

It is used to rename an old file name with new file name. Renames a file / directory or
files / directories.

10) DEL (delete a file) :-

Syntax = C:\>DEL <filename.Ext>


Page 5 of 11 Chapter 2: Dos Commands

This command is used to delete a single file.

11) MD (create directory) :-

Syntax = C:\>MD <directory name>

It is used to create a new directory of subdirectory.

12) CD (change directory) :-

Syntax = C:\>CD <directory name>

It is used to change from one directory or subdirectory to other directory or subdirectory.

Syntax: C:\> CD..


It will move one level back to parent directory.

C:\> CD\
It will directly move to the root directory from any logged subdirectory.

13) PATH :-

The purpose of this command is to provide access to files located in other directory path
or other disk. User can access only those files that have extension .EXE, .COM, BAT. By
setting the path to these executable files user can execute them from anywhere on the
DOS prompt. There are three options for setting of path to executable files.

To set the path:

Syntax = C:\> PATH <Drive name:\Directory name>


Ex: C:\>PATH C:\TC\BIN

To see the path:

Syntax = PATH
It will display the path set by user as PATH = C:\TC\BIN;

To remove the path:

Syntax = PATH;

14) COPY (copy file) :-

Syntax = C:\>COPY <source path> <target path>


C:\> Copy A:\*.* C:\AIMIT

It copies all the files from floppy disk drive A in to hard disk in directory AIMIT.
Page 6 of 11 Chapter 2: Dos Commands

It is used to copy files from one directory to the same directory or another directory or
disk.

15) RD (remove directory) :-

Syntax = C:\>RD <sub-directory name>

This is used to remove a directory or subdirectory. If user wants to remove a directory or


subdirectory, then first delete all the files and subdirectory in it. User can remove only
empty directory or subdirectory.

16) EXIT (to come out) :-

Syntax = C:\>EXIT

It is used to come out of the DOS mode.

17) PROMPT :-

It is used to change the Windows command prompt. It is followed by space and a dollar
sign ($) followed by special character.

Syntax = C:\>PROMPT <text>

Text specifies a new command prompt. Prompt can be made up of normal characters and
the following special codes:

$Q ## = (equal sign)
$$ ## $ (dollar sign)
$T ## Current time
$D ## Current date
$P ## Current drive and path
$V ## Windows version number
$N ## Current drive
$G ## > (greater-than sign)
$L ## < (less-than sign)
$B ## | (pipe)
$H ## Backspace (erases previous character)
$E ## Escape code (ASCII code 27)
$_ ## Carriage return and linefeed

Note: Type PROMPT without parameters to reset the prompt to the default setting.
Page 7 of 11 Chapter 2: Dos Commands

 External Commands

External Commands are conventional program files. These files can be deleted, copied,
modified and even renamed. These files can be deleted, copied, and renamed. These
commands can be displayed by typing DIR at the dos prompt. Ex: EDIT, CHKDSK,
DELTREE, FORMAT, SCANDISK, and DOSKEY etc.

Some commonly used Dos External commands are:

EDIT ATTRIB CHKDSK DISKCOPY DISKCOMP DELTREE


FORMAT FDISK LABEL MORE MOVE PRINT
SCANDISK SORT SYS XCOPY DOSKEY

1) EDIT (modify file):-

Syntax = C:\>EDIT <filename. Extn>

It is used to create a new file of modify the contents of an existing file. Edit commands
has few pull down menus which can be activated by pressing Alt key.

2) ATTRIB :-

This command is used to change the attribute of a file i.e. user can use ATTRIB
command to make a file “read only” which prevents the file from the change of contents.

Syntax = C:\> ATTRIB <filename> attributes


+R Read only
-R Remove read only
+H Hide the file
-H Dehide the hidden file

3) CHKDSK (configuration of the disk) :-

It returns the configuration status of the selected disk. It returns the information about
Volume serial number, Total disk space, space in hidden files, space in directories, total
memory and free memory space.

Syntax = C:\> CHKDSK <<drive name>>


C:\>CHKDSK A:

Volume Serial Number is 12FC-0A35

1,457,664 bytes total disk space


512 bytes in 1 hidden file
4,096 bytes in 5 directories
1,019,392 bytes in 19 user files
433,664 bytes available on disk
512 bytes in each allocation unit
Page 8 of 11 Chapter 2: Dos Commands

2,847 total allocation units on disk


847 available allocation units on disk

655,360 total bytes memory


615,168 bytes free

4) DISKCOPY (copy data from one disk to another) :-

Syntax = C:\>DISKCOPY <source drive> <destination drive>


Or C:\>DISKCOPY A: B:

It is used to make duplicate copy of a disk like Xerox copy. It first formats the target disk
the copies files from source disk to target disk. It makes the perfect replica of the source
disk.

5) DISKCOMP (compare two disk) :-

Syntax = C:\>DISKCOMP <source drive path> <destination drive path>


Or C:\>DISKCOMP A: B:

It is used to compare two disks to find out whether they are identical or not. They
compare tracks, sectors, etc. This command is generally used after DISKCOPY
Command.
: It is used to compare two disks to find out whether they are identical or not. If users try
to compare two dissimilar disks DISKCOMP will display an error message (like this
compare has error on side<<no.>>, track<<no.>>). If comparing successful the message
like Compare OK is displayed

6) DELTREE :-

Deletes a directory and all the subdirectories and files in it.

To delete one or more files and directories:


DELTREE [/Y] [drive:] path [[drive:] path [...]]

/Y Suppresses prompting to confirm you wants to delete the subdirectory.


[drive:] path Specifies the name of the directory you want to delete.

Note: Use DELTREE cautiously. Every file and subdirectory within the specified
directory will be deleted.

7) FORMAT : -
Formats command is used to make a disk usable for operating system by dividing the
disk into tracks and sectors.

Syntax = FORMAT <<drive name/switches>>


Page 9 of 11 Chapter 2: Dos Commands

/Q Performs a quick format.

/S Copies system files to the formatted disk.

8) FDISK :-

This command is used to configure a hard disk for use with MS-DOS. We can use this
command to make partition of hard disk and can organize cylinder on it to store data.
Each partition of hard disk can have its own operating system.

Syntax = FDISK [/STATUS] /X

/STATUS Displays partition information.

Fixed Disk Drive Status


Disk Drv Mbytes Free Usage
1 9766 100%
C: 9766
/X Ignores extended disk-access support. Use this switch if you receive disk access
or stack overflow messages.

C:\>Fdisk
It will display 4 options:
Current fixed disk drive: 1

1. Create DOS partition or Logical DOS Drive


2. Set active partition
3. Delete partition or Logical DOS Drive
4. Display partition information.
Enter Choice [1]

When one select the option 1, further three options are displayed.
Choose one of the following:

1. Create Primary DOS Partition


2. Create Extended DOS Partition
3. Create Logical DOS Drive(s) in the Extended DOS Partition
Enter Choice [1] to create Dos partition.

9) LABEL :-

Creates, changes, or deletes the volume label of a disk.

Syntax = C:\> Label <Drive name>


C:\> Label AIMIT
It will change the label of the disk to AIMIT.
Page 10 of 11 Chapter 2: Dos Commands

10) MORE :-
It displays output one screen (page by page) at a time. This command is used with DIR
and TYPE command.

Syntax = C:\> Type <Filename>| more.

11) MOVE :-

It is used to move files or directories from one directory to another.

Syntax = C:\> Move <Source path> <Target path>

12) PRINT :-

This command is used to print text files.

Syntax = C:\> Print <Filename>

13) SCANDISK :-

This command is used to repair & check various disk errors, file allocation table(FAT) &
other disk related errors.

Syntax = C:\>SCANDISK <<drive name>>

14) SORT :-

This command sorts the data in alphanumeric order which can be ascending or
descending. This can be used with other commands by using pipe symbol in many
combinations.

Syntax = C:\> Dir | Sort

15) SYS :-

This command is used to transfer system files to the target disk that is to make target disk
bootable by copying BIO.COM, IO.SYS, MSDOS.SYS, COMMAND.COM, DOS.COM
on the target disk. The BIO.COM and DOS.COM are hidden files.

Syntax = C:\> Sys <Drive Name>


C:\> Sys A:

16) XCOPY :-

It is used to copy files as well as directories from source to destination.


Syntax = C:\> Xcopy <<source path>> <<destination path>> /switches
Page 11 of 11 Chapter 2: Dos Commands

/E Copies the directory even if they are empty.


/P Prompts (Y/N) before copying the files to destination.
/S Copies all files & subdirectories source to destination.
/D Copies files changed on or after the specified date.
/Y Overwrites existing files without prompting.
/-Y Prompts you before overwriting existing files.

17) DOSKEY :-