4.2 Disk Operating System (DOS)
4.2.3 Overview of basic DOS commands
Internal versus External DOS Commands
DOS contains commands that are built into the operating system (internal) and those that must be executed from a file (external). Basic commands are generally internal and more advanced commands are usually external. External commands are stored on disk for future use. Internal commands are located in the COMMAND.COM program and are loaded into memory during bootup. Examples of internal and external commands are discussed later in this chapter.

What is a command line?
Normally, the operating system provides the system user interface. In DOS, the main user interface is the command line. The command line is the space immediately following the DOS prompt, C:\> where C:\ represents the hard disk drive root directory, and ">" is known as the prompt. All the DOS commands are typed to the right of the prompt and executed by pressing the return (ENTER) key on the keyboard. All DOS functions can be entered and executed from the command line.

Commonly used DOS Commands and Switches
DOS commands are used to tell the disk operating system to perform a specific task. Placing one or more software switches at the end of the basic command can modify many of the DOS commands. Switches are options that can be added to a command that will modify the output of the command. A switch is added to the command by adding a space, a forward-slash (/), and a single letter. The format is as follows:

COMMAND (space) /switch,  for example, C:\>DIR /w

In the example given above, the /w is a switch. The /w will modify the dir command by presenting the screen output information in a "wide" format, that is across the screen. The rest of this section will focus on some commonly used DOS commands and the switches that go with them. These commands are helpful when doing various OS installations including Windows.

  • Attrib command – Used to display, set, or remove one or more of the four attributes. They are read-only, archive, system, and hidden. They can be assigned to files and directories. It is an external DOS command. Commonly used switches and format: ATTRIB [ + | - R] [ + | - A] [ + | - S] [ + | - H] [directory|filename] [/S]
    • (+) – Sets an attribute, while (-) Clears an attribute
    • R – Read-only file attribute
    • A – Archive file attribute
    • S – System file attribute
    • H – Hidden file attribute
  • Del command – Deletes named files. DEL and ERASE are synonymous. The commonly used switch:
    • /P – Prompts for confirmation before deleting each file.
  • Edit command – Allows a user to view, create and or modify computer files. It is an external command. Commonly used switches:
    • /B – Forces monochrome mode.
    • /H – Displays the maximum number of lines possible for the hardware.
    • /R – Load file(s) in read-only mode.
    • [file] – Specifies initial files(s) to load. Wildcards and multiple file specs can be given.
  • Format command – Used to erase all the information from a computer diskette or hard drive. It is an external DOS command. The format command will be used in a future lab to prepare the hard drive for the Windows OS. Commonly used switches:
    • /Q – Performs a quick format.
    • /S – Copies system files to the formatted disk.
  • FDISK – Allows the user to delete and/or create partitions on the hard disk drive. It is an external DOS command. The FDISK command is commonly used to prepare the hard drive for the Windows OS installation. Commonly used switches:
    • /STATUS – Displays partition information.
  • Scandisk – DOS program designed to check the integrity of a computer hard disk or floppy drive. Commonly Used Switches:
    • /all – Checks and repairs all local drives at once.
    • /checkonly – Checks drive for errors but will not make repairs.
    • /autofix – Automatically fixes errors. Saves lost clusters by default as files in the drive's root directory.
  • The cd, mkdir, rmdir, deltree – Do not use switches with these commands. Here is a brief description of the commands:
    • cd – Changes the current directory on the specified drive.
    • mkdir (md) – Creates a new directory.
    • rmdir (rd) – Removes a subdirectory. This command will not remove file and subdirectories within a directory.
    • deltree – Deletes (erases) a directory including all files and subdirectories that are in it.
  • The mem command – Used to display a table showing how memory (RAM) is currently allocated. External command. Commonly used switches:
    • /C – Lists the programs that are currently loaded into memory and shows how much conventional and upper memory each program is using.
    • /D – Lists the programs and internal drivers that are currently loaded into memory.
    • /F – Lists the free areas of conventional and upper memory.
    • /P – Pauses after each screen of information.
  • Copy command – Usually used to copy one or more files from one location to another. COPY can also be used to create new files. By copying from the keyboard console (COPY CON:) to the screen, files can be created and then saved to disk. Commonly used switches include:
    • /Y – Causes COPY to replace existing files without providing a confirmation prompt.
    • /-Y – Displays a confirmation prompt before overriding (copying over) existing files.
    • /A – Copies ASCII files. Applies to the filename preceding it and to all following filenames.
    • /B – Copies binary files. Applies to the filename preceding it and to all following filenames.
    • /V – Checks after the copy to make sure that a file was copied correctly. If the copy cannot be verified, the program will display an error message.
  • More Command – Displays output one screen at a time. The command syntax is simple (file name in the syntax equals the name of the file to be output):

    C:\> more filename

Figure summarizes the information provided in the preceding paragraphs, on commonly used DOS commands.

 
Lab Activity  (PDF, 33 KB)
  In this lab, students will able to navigate the DOS command line. Students will also be able to perform basic file management tasks.
   
Worksheet  (PDF, 6 KB)
  DOS Commands