MS Dos
MS Dos
DOS DOS is an acronym for Disk Operating System. It was developed by Bill Gates
and Paul Allen of Microsoft Corporation, USA in 1980. - MS-DOS (Microsoft)
Internal commands are integral part of the COMMAND.COM. These are simple routines
within the command processor. But, external commands are stored on disk as a separate file.
Let us discuss some of the most commonly used internal and external commands.
Click Start Button →Choose Program →Choose Accessories →Click Command Prompt as
shown below:
Or Click Start Button Choose Run Type cmd in the Open tab as shown below:
2. DIR - Options There are many options associated with DIR command.
Below table illustrates the option and its meaning.
Table: Directory command options
Option Meaning
DIR/P Page wise listing of directories and
files
DIR/W Widthwise listing of directories
and files
DIR/A Display all directories and files
DIR/B Display in bare format (No heading
information and summary)
DIR/O Listing files in sorted order
DIR/S Display specified files in all
directories and subdirectories
DIR/L Display in lowercase letters
DIR/AD Display only directories
DIR/AR Display read-only files
DIR/AH Display only hidden files
DIR/AA Display only files accessible for
archiving
DIR/AS
3. COPY - This command is used to copy one file to another. It duplicates the existing file.
The syntax is C:\>copy OldFileName NewFileName
Here, OldFileName is an existing file and NewFileName is the file that copies the contents of
OldFileName.
Examples: i) C:\> copy odd.c ABC.C
ii) C:\> copy exp1.c prg.c
Copying of a file from one directory to another is also possible. The syntax changes.
copy drive:pathname drive:pathname
Here pathname indicates the location of the file to be copied.
Example: i) C:\> copy C:\DOS\CONFIG.SYS A:\PBK\CONFIG.SYS
ii) C:\> copy C:\TC\bin\sort.c D:\PETiis.c
5. TYPE - This command is used to display the contents of a file. Its syntax is as follows.
Type FileName
Examples: i) C:\> Type EXP.CPP
ii) C:\> Type prog.c
6. COPY CON - This command is used to create a new file from the console. Its syntax is as
follows.
COPY CON FileName
Suppose you want to create a file FirstProg.c, and then type it as
C:\> copy con FirstProg.c
and hit ENTER key. The cursor (location marker) moves to the next line. Now type
whatever the information you want. After completion of typing, you can stop it by
pressing simultaneously CTRL and Z keys. And, then press ENTER key.
7. MKDIR - This command is used to create new directories. Its syntax is as follows.
MKDIR DirName Where, DirName is the name of the new directory to be created.
8. CD - CD stands for Change Directory. It changes the environment from one directory to
other. Its syntax is as follows.
CD DirName
Example: C:\> CD TC When this command is executed you will find on the screen
C:\TC>
And, if you want to go back to the prior environment then execute CD as
C:\TC>CD.. OR C:\TC>CD\
This brings you back to C:\>(Root directory).
The above commands are used in below window.
9. RD - This command is used to remove or delete the directories. Before using this
command ensures that the directory to be deleted must be empty. Otherwise the directory will
not be deleted. The syntax is as follows.
RD DirName
Example: C:\> RD XYZ
It deletes the directory XYZ in root directory (i.e. C:\>).
10. DEL - This command is used to delete or erase a file. Its syntax is as follows.
DEL FileName
Example: C:\> DEL prime.C
The file prime.C is erased from root directory.
12. DATE - This is used to display the current date or set the new date. Type the following
command
C:\>DATE and press the ENTER key. You will find on the screen
13. TIME - This command is used to display the current time or set the new time. Type the
following command.
C:\> TIME and press the ENTER Key. You will see on the screen:
If you wish to set a new time, type your time in hour -minute-second (HH-MM-SS) format at
the end of the second line. If you don't want to set the new time, simply press the ENTER
Key.
14. VER - This displays the version of DOS installed in the system. There are different
versions of DOS, such as DOS 1.0, DOS 2.0, DOS 4.0, DOS 5.0, DOS 6.0, DOS 6.20, DOS
6.22 and DOS 7.0. Example: C:\>VER
15. PATH - This displays the current path or sets a search path for executable files. By
specifying the path, the executable files in any directory can be invoked from any other
directory. Its syntax is as follows.
PATH drive; path
Example: C:\> PATH C:\DOS; C:\DBASE;
It enables you to execute DBASE commands at DOS prompt and DOS command at DBASE
prompt. It also enables to execute commands of both DOS and DBASE commands at C: >.
It enables you to execute DBASE commands at DOS prompt and DOS command at DBASE
prompt. It also enables to execute commands of both DOS and DBASE commands at C: >.
.bak : Used by programs and users to make a copy of an existing file for safety and/or
archive purposes.
External Commands are such short programs or utilities which are available on floppy /
hard disk and are loaded in the memory of the PC when specially asked for. Some of the
external commands that are often used are format, attrib,
1. FORMAT – This command is used to format the disks. Formatting is the process of
making the disks usable with DOS. It also identifies and marks the number of tracks, sectors
and cylinders. Its syntax is as follows.
2. ATTRIB– This is used to view or change the attributes associated with files such as read
only, hidden, archive and system files.
To make files hidden +H option is used To make files read only, +R option is used The
general format is as follows
Create a file
-
COPY CON FILE1.TXT
. Now just hit a few randomkeystrokes to put anything in the file. When finished, hit F6 and
thenenter. You will now see the message "1 file(s) copied" which means you just created a file called
file1.txt in the 240temp directory.6.
Exercise
1. Copy FILE1.TXT and make a file2.txt, file3.dat, file4.xyz, file5.txt. Payattention to the names
and extensions of the files.
2. List out the directory and see ALL the newly created files.3.
3. Now you just want to see a list of the files that have TXT as their extension.
4. Make a copy of file4.xyz and call it first.dat5.
5. Create a subdirectory under the directory you're currently in. Call this newdirectory TESTDIR
6. Copy all the files with an extension of DAT to the new subdirectory.
7. Change directories to the newly created directory and list all the files inthere.
8. Delete file3.dat.
9. Go back up to the parent directory of the current directory you are in.
10. List all the file with an extension of DAT in the current directory and theone you just created.
Use only one command to do so.
11. Change the name of file1.txt to file6.txt
12. Delete the directory you created (TESTDIR). Are you able to do this? Why or Why not ?.
13. Change directories to the TESTDIR directory. Delete the remainingfile. Change directories up
to the parent directory (up one level) and nowdelete the directory.
14. List all the files that start with FI and have an extension of TXT.
15. List all the files that start with the word FILE, then a single digit anextension of TXT.
Exercise-2:
1. Create two new subdirectories labeled: PUBLIC and PRIVATE in the C:\Work directory.
2. Create twosubdirectories labeled PROGRAMS and DATAS in the PUBLIC directory .
3. Create a subdirectory labeledDOCUMENT in the PRIVATE directory.
4. In the DOCUMENT directory create a text file named mylive.txt, and write your
firstname,lastname, birth date in this file.
5. Copy the file mylive.txt to the DATA directory.
6. Rename the file from mylive.txt to your lastname, for example: kowalski.txt.
Exercise 3:
1. From the level of the C:\Work directory create a directory labeled LAB, and then create
twosubdirectories labeled: LAB2A and LAB3A in the LAB directory.
2. In the LAB3A directory create a subdirectory labeled LAB4.
3. In the LAB2A directory create files: file1.txt and write your firstname and lastname in this
file,file2.txt and write the number of your index in it.
4. Place a data from the files: file1.txt and file2.txt into mydata.txt file.
5. Display the contents of the file mydata.txt.
6. Copy the file mydata.txt to the LAB3 directory renaming it to filescal.txt.
7. Rename the file from mydata.txt to mydata.lst.
8. Enable the "read only" attribute for the file filescal.txt.
9. Enable the "hidden" attribute for the LAB4 directory.
10. Enable "read only" and "hidden" attributes for the file file2.txt."
11. Create a directory: C:\WORK\LABOR.
12. Remove the structure from the LAB directory to the LABOR directory, remember about
thehidden files and directories and the empty directory.
13. Place the information about the structure of the C:\WORK directory in the file inflab.txt, and
theinformation about the attributs of this structure in the file infolab2.txt.
14. Delete the tree of the C:\WORK\LAB directory.