Dos Commands

What is DOS?

DOS stands for Disk Operating System. DOS controls the computer’s hardware and provides an environment for programs to run. This system program must always be present when working with our computer.

Why We Need DOS

There are a variety of reasons why we need DOS. A few of them are listed below:

DOS controls the flow of information between we and the computer (translator).

  1. DOS allows to store information on our computer.
  2. DOS allows us to retrieve information stored on our computer.
  3. DOS interprets and translates the software we have on our computer.
  4. DOS gives us access to all its function (i.e. saving, copying, and printing files).

Check the Date and Time

We can  check or change the date and time once it has been set. The procedure to do this is as follows:

Directions:

  1. Type: date and press return.
  2. If the correct date is displayed, simply press return. If the date is incorrect, type the correct date and press return.
  3. Type: time and press return.
  4. If the correct time is displayed, simply press return. If the time is incorrect, type the correct time and press return.

 VER Command

To see the version of DOS we use  VER command.

Directions:

Type: ver and press return.

 VOL Command

To see the label of  the volume in the specified drive.  we use  VOL command.

Directions:

Type: VOL and press return.

 

Directory Command

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

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

Directions:

  1. At the C:\> type: dir and press return.
  2. The list of files will be shown on the screen.

NOTE: At the end of the listing, there is a line that shows the number of bytes free on the hard drive.

View a Wide Listing of Files

When we need to quickly view our files, we can add a /W to the directory command. This will display our files into five columns on the screen.

Directions:

  1. Type: dir/w and press return.

NOTE: Use this command when we are not concerned with looking at the file size or the date it was created.

Recall a DOS Command

The F3 function key can be used to recall the last DOS command we typed in. If we would like to retrieve a previously entered command, we can also press the up arrow key continuously until we reach the desired command we  are looking for.

Check for a Single File

Instead of using the directory command to look for one particular file, we can type the name of the file after the DIR command at the C:\> prompt.

Directions:

  1. Type: dir format.com (filename.extension) and press return.
  2. The screen will display a listing of the file or a file not found message.

Check for a Group of Files

The * symbol is called wildcard and stands for any character or group of characters. This is helpful when we want to list files that start with a particular letter or group.

Directions:

  1. Type: dir c* and press return.
  2. All filenames that begin with the letter C will be listed.

Clear the Screen

When the screen get full of information, we may want to clear it. To do this, type CLS at the C:\> prompt and press return.

Create a File with DOS

Directions:

  1. Type: copy con first.txt and press return.
  2. Type the message as the following :

This is my first file.

3.Press the F6 function key (^Z) and press return.

DOS gives we a message that 1 File(s) has been copied.

Viewing The Content Of File

Directions:

  1. Type: Type first.txt

NOTE: We can also use the COPY command to print a file by typing: copy quick.ltr prn and press return.

Copy a File

We can use the COPY command to copy one file to another.

Directions:

  1. Type: copy first.txt  second.txt and press return.
  2. DOS will tell we one file has been copied.

NOTE: Filenames cannot be more than eight characters in length. File extensions cannot be more than three characters in length.

Copy a File with a New Extension

We can also use the COPY command to copy the file with a different filename extension.

Directions:

  1. Type: copy first.txt  second.doc and press return.

Rename a File

The RENAME command lets we rename a previous file with a new name.

Directions:

  1. Type: ren second.txt sec.txt and press return.

Create a Subdirectory

To create a subdirectory, we will need to use the MAKE DIRECTORY command, MD. Directions:

  1. Type: md  info and press return.

.

Move to a Subdirectory

Once we have created a subdirectory, to move to that directory, we will use the  CD command.

Directions:

  1. Type: cd info and press return.

Move to the Parent Directory

DOS has a quick way to move from the current directory back to the parent directory.

Directions:

  1. Type: cd.. and press return.

Copy a File into a Subdirectory

The COPY command lets we copy files from one directory to another.

Directions:

  1. Type: copy first.txt info and press return.
  2.  TO  see Type: dir info and press return.

Delete a Single File

To remove  file in DOS we use the DELETEcommand, also known as DEL.

Directions:

Type : DEL first.txt and press return.

Remove a Subdirectory

To remove  subdirectory in DOS we use the REMOVE DIRECTORYcommand, a.k.a. RD.

Directions:

1. Type : rd info  and press return.

2. If we cannot be in the subdirectory that we wish to remove. We will need to return to the root directory (C:\> prompt).

Directions:

  1. Type: cd.. and press return.
  2. We should be back in the root directory.
  3. Type: rd \info and press return.

 

Internal vs External commands

INTERNAL COMMANDS

 

  • These are those commands which are contained in command.com files of MS-DOS.
  • These are those functions that are built into the command interpreter.
  • There is no need of any external file in computer to read internal MS-DOS command.
  • These commands can be used as long as DOS is running on the system. Internal commands do not vary from system to system.
  • These are ver, time, del, md, cd, copy con, cls, date, vol, ren, copy etc.

 

EXTERNAL COMMANDS

 

  • These are those commands which are not in-built in MS-DOS.
  • External commands are those which are not included in the interpreter.
  • There is a need of an internal file in the computer to read external MS-DOS command.
  • External command may vary from system to system. This means any two computers with same version of MS-DOS may have same internal commands, but may have different external commands.
  • These are tree, xcopy, diskcopy, more, print etc.

Diskcopy

The diskcopy  allows us  to copy the complete contents of a diskette to another diskette.It works only with  floppy disk.

Syntax:

C:\>Diskcopy <Source Drive> <Target Drive>

Example

C:\> Diskcopy a:b:

Xcopy

The xcopy command is  used to copy one or more files and/or folders from one location to another location.

Syntax:

C:\>Xcopy <Source Drive> <Target Drive>

Example

C:\> Xcopy  a:b:

Switches with Xcopy

/w = We use the /w option to present a “Press any key when ready to being copying file(s)” message. The xcopy command will begin copying files as instructed after we confirm with a key press.

Example

C:\> Xcopy  a:b:/w

 

/s = We use this option to copy directories, subdirectories, and the files contained within them, in addition to the files in the root of source. Empty folders will not be recreated.

Example

C:\> Xcopy  a:b:/s

Attrib

This  command is used to change the attribute of a file . By using attrib command we can make a file read only ,hide etc.

Syntax:

C:\>Attrib –r <file name>

C:\>Attrib +r <file name>

C:\>Attrib –h <file name>

C:\>Attrib +h <file name>

C:\>Attrib -a <file name>

C:\>Attrib +a <file name>

 

 

Example

c:\> Attrib-r Test.txt

 

Format

This command prepares a new disk for use.

Syntax:

FORMAT <DRIVE>:

Example

FORMAT  B:            Formats the disk in drive

FORMAT  B:/s         Formats the disk in drive B and transfer                                                                                              the DOS to it.

FORMAT  B:/B         Formats the disk in drive B and

reserves space for DOS.

Scandisk

This utility detects,diagnoses and repairs disk errors.

Syntax:

c:\>Scandisk

Chkdsk

This command checks the status of a selected disk.

It display several informations like:

  1. The total disk space.
  2. The total disk space occupied and the number of files.
  3. The amount of  disk space available for use.
  4. The amount of  memory available for use

Syntax:

c:\>chkdsk

Move

This command moves directories and files to another location on the same disk.

Syntax:

C:\>Move [Source Directory][Target Directory]

Example

c:\>move c:\Mydir\*.* c:\Newdir

Undelete

This command is used to recover files that have been previously erased.

Syntax:

C:\>Undelete <File name>

Example

C:\>Undelete Newdir

For : More Material on Php

To Buy NTSE : The Essential Guide

To Learn Computer/Math/NTSE/Sanik School / JNV School Contact Abhishek Jha here

Untitled

kindly Send your feedback/suggestions/question/doubts