DOS is almost extinct. People hardly use MS-DOS to operate their computers anymore. Even the syllabus of Computer Operator has removed the MS-DOS section and replaced with Command-Line Operations. Command Line Operation is performing some actions from DOS Prompt. However, it will be harder for you to understand the concepts without knowing the fundamentals of DOS, I will be briefly touching the MS-DOS to focus more on the required commands for your syllabus.
DOS Concept
Booting
Booting is the process of loading system files from disk into the main memory of computer. Booting process starts a computer or restarts if user chooses to do so.
Booting is also known as booting up which is the initial set of operations that a computer system performs when electrical power is switched on. The process begins when a computer that has been turned off is powered on, and ends when the computer is ready to perform its normal operations. Booting operation typically involves performing power-on self-test, locating and initializing peripheral devices, and then finding, loading and starting an operating system. Many computer systems also allow these operations to be initiated by a software command without cycling power, in what is known as a soft reboot. Some of the initial operations might be skipped on a soft reboot (quick boot). A boot loader is a computer program that loads the main operating system or runtime environment for the computer after completion of self-tests.
Booting Process
When a computer starts up ( obviously by pressing the power button), the first thing that occurs is it send a signal to the motherboard which in turn starts the power supply. After supplying the correct amount of power to each device, it sends a signal called “Power OK” to BIOS which resides on the motherboard.
Once the BIOS receive the “Power OK” signal, it starts the booting process by first initializing a process called POST (Power On Self Test). POST first check that every device has the right amount of power and then it check whether the memory is not corrupted. Then it initializes each device and finally, it gives control to BIOS for further booting.
Now the final process of booting begins. For this the BIOS first find 512 bytes of image called MBR (Master Boot Record) or Bootsector from the floppy disk or hard disk which is used for booting. The priority of boot devices is set by the user in BIOS setting. The normal priority is floppy disk first, then hard disk.
Once BIOS finds the bootsector it loads the image into memory and execute it. If a valid bootsector is not found, BIOS check for next drive in boot sequence until it find valid bootsector. If BIOS fails to get valid bootsector, generally it stops the execution and gives an error message “Disk boot failure”.
It is bootsectors responsibility to load the operating system in memory and execute it. [Source: ViralPlate.net]
Booting are of two types based on from which state a computer is booted – cold boot and warm boot.
Booting by turning on a computer by pressing power button is called cold boot, because the computer was in cold state (off state). If you restart a computer by pressing Alt+Ctrl+Del, it is known as warm boot because the computer was already warm.
Boot Loader
A boot loader, also called a boot manager is a small program that places the operating system of a computer into memory. When a computer is powered up or restarted, the basic input/output system (BIOS) performs some initial tests and then transfers control to the master boot record (MBR) where the boot loader resides. Most new computers are shipped with boot loader for some versions of Microsoft Windows or the Mac OS. [Source: Microsoft Chat]
Microsoft Disk Operating System (MS DOS)
MS-DOS is a popular single-user operating system. It was developed by Microsoft Inc in 1981 for IBM range of computers. It was developed for 16-bit microcomputers.
- It is a single user CUI operating system.
- It is machine independent (supports various computer languages)
- Supports pipes and I/O redirection
- Supports both floppy and hard disks
- Supports flexible file allocation
Main files required to start up a computer in DOS are io.sys (input / output system), MSDOS.sys and command.com. IO.SYS is a hidden system file that contains device drivers, serial port and real-time clock. MSDOS.SYS is another hidden system file that contains the software that makes up the heart (kernel) of the operating system. COMMAND.COM is the command interpreter for MS DOS.
Directory
a directory is a table of contents for a disk. It contains the information such as file names, their size, modified dates, file properties (attributes) and so on. Directories let users to organize files in convenient categories.
A directory may contain other directories inside it. The one which contain other directory inside is known as parent directory and the inner directories are sub directory. A directory which is currently working directory is known as default directory or working directory.
Every disk has one essential directory known as root directory which exists even when a user has not created any directory in the disk. The root directory is denoted by a back slash ( \ ).
File
A file is the collection of related information stored in a computer. A file is the basic unit of storage that enables a computer to distinguish a set of information from other. Each file is identified by its name which is the combination of the file name (maximum 8 characters) and extension (maximum 3 characters). The first part filename identifies the file and the second part, the extension, indicates the type of file.
There are different kinds of files created and stored in computer – Text files (.txt), Executable files (.exe), command file (.com), backup file (.bak) help file (.hlp), batch file (.bat), system file (.sys).
The Two Special Files of DOS
MS DOS has two special files – config.sys and autoexec.bat. The first file is used to specify the settings of computer such as the allowed number of file or buffer size, location of devices and so on. The second file is used to execute some commands or programs automatically every time when computer finishes booting. Generally disk scanning, virus checking, specifying path etc are specified in autoexec.bat file.
Path
A file is specified in disk with reference to the drive letter, directory, subdirectories in which it is located. For example to refer a file named ‘mytext.txt’ which is stored in ‘docs’ subdirectory of ‘users’ directory of ‘D’ drive, we use d:\users\docs\mytext.txt. In this specification the portion d:\users\docs tells where mytext.txt file is stored and it is called the path.
A path can be relative or absolute. In the previous example, the path is absolute. This means it will access to that file regardless to your current location or current working directory. But if you specify a file such as \jan\expense.txt, this path \jan\ is a relative path. It tells the file is in the ‘jan’ folder which is inside current directory. Now, if your current directory is changed, this path might not be valid.
There is a ‘Path’ command in DOS which is used to set the program directories in DOS so that you can execute programs by typing its file name without specifying the path.
WildCard Characters
There are a few characters used in DOS which possesses special meaning. For example, the question mark is used in DOS while specifying a file name to mean ‘any but only one character’. If you type DIR ???.txt, DOS will try to list files with maximum 3 character filename and txt as an extension.
Similarly, An aestrict * is used to mean any number of any character. And, Greater than symbol > is used to redirect. For example dir > ram.txt will send the output of dir command to ram.txt file. A colon “:” is used to mean drive.
Command
A command is an instruction to the computer to carry out some tasks when issued by the user.
MS-DOS command usually has 3 parts – a command name, parameter, and switch. Command name tells the computer what to do. Parameter tells the computer to what the command should effect. Parameters are the input values to command. Options or switches are extra instructions related to that command.
In case of following command:
COPY C:\RAM.TXT D:\NEWFILE\RAM.TXT/v
COPY is command name (keyword). c:\ram.txt d:\newfile\ram.txt are the parameter. We provided two files as input to the command, one the source to copy and another the destination. The final part /v is the switch or option which adds the task of verifying after copy.
MS-DOS commands are internal or external depending upon whether the program code of that command is written inside command.com file itself or is in a separate file external to command.com.
Some internal commands are: CD, CHDIR, CLS, COPY, DATE, DEL, DIR, MKDIR, MD, PATH, PROMPT, REN, RMDIR, RD, TIME, TYPE, VOL, VER
Some external commands are: ATTRIB, BACKUP, CHKDSK, DISK COMP, DISKCOPY, FORMAT, LABEL, MORE, SYS, TREE, XOCPY, DELTREE
DOS Commands for Basic Computer Operation
In the beginning, Windows was a GUI extension of the operating system that runs on top of MS-DOS. From Windows 95, it was released as a separate operating system. After the popularity of Windows, general computer users don’t need to enter commands on the prompt to perform tasks. A simple click, double-click or drag-and-drop can perform same tasks that required to enter commands with specific switches and parameters.
Though we rarely use the command prompt to issue instructions to the computer, DOS prompt can be truly helpful in some cases and the syllabus of Computer Operator demands you to learn a few command line operations.
DOS Prompt
A prompt is an indicator in DOS that displays where to enter a command and whether DOS is ready to accept the new commands. By default, C:\> is displayed as prompt. DOS displays prompt only when it is ready to accept a new command. For example, if you recently have entered a command and DOS is still processing it, you won’t see a prompt. When it finishes executing the previous command and the task is completed, you can see the prompt to type the new command again.
The default DOS prompt can be changed with PROMPT command. The prompt command accepts one parameter as a format string. You can combine more than one format code to create your desired prompt. Following are some common prompt codes.
- $P –> Display the path in prompt. Useful to know the current directory
- $G –> Greater than symbol. Useful to indicate where the prompt ends.
- $L –> Less than symbol.
- $t –> Current system time. Include system time to record at what time the command was entered.
- $D –> Current system date.
- $N –> Current drive letter
- $Q –> Equals to symbol
- normal text –> The text is used as prompt.
Please click here to read more about PROMPT command.
Example:
PROMPT Date $Q $d ==> Date = Thu 03 / 22 / 2012
PROMPT $N ==> C
PROMPT $D $G ==> Thu 03 /22 /2012 >
PROMPT $PRG ==> C:\>
System Date and Time
Every computer system has a clock and you can display and/or change the date and time if it is not correct. DOS provides DATE and TIME commands for this purpose.
- Enter DATE on command prompt to display the system date. Press enter to proceed without changing date.
- Enter DATE <any valid date> on command prompt to set the new date as your system date.
- Enter DATE and press enter. Type the new date in mm/dd/yy format to set new date.
- Enter TIME command on prompt and press Enter to display system time. Press Enter again to proceed without changing time.
- Enter TIME <any valid time> on prompt to change system time.
- Enter TIME and press Enter. Type new time and press enter to change system time.
- Note if you supply only 4 with time command it will set 4:00:00am as system time.
- If you enter 4:30 with time command, it will set 4:30 am as system time.
Click the command names to read more about these commands:- TIME, DATE
Handling Text Files
In MS DOS, you can create new text files (ASCII files), display the contents of existing files or edit existing files if necessary. MS DOS provides following commands to work with files:
- COPY CON [path] filename => to create new file
- TYPE [path] filename => to display the contents of file. This is like user commanded the computer to type a file that was previously saved.
- EDIT [path] filename => to edit the content of existing file.
Click the command names to read more about these commands:- COPY, TYPE, EDIT,
Examples:
1) Create a text file named “ecourse.txt” with following text:
ICT Trends runs different eCourse to help candidates of Computer Operator to prepare their exam. It has automated eCourse that runs through emails.
Solution:
Step 1: Enter following command and press Enter.
C:\> COPY CON ecourse.txt
Step 2: Now the prompt will not be displayed but a blinking cursor waiting fro you to enter text. Type following text.
ICT Trends runs different eCourse to help candidates of Computer Operator to prepare their exam. It has automated eCourse that runs through emails.
Step 3: Press Ctrl+Z or F6 key on your keyboard to save the file. If you made any mistake for example wrong file name, you exit without saving the file by pressing Ctrl+C.
MS-DOS will display 1 file(s) created if it successfully saved the file.
2) Display the contents of file ecourse.txt on screen
Solution:
You can display the content of an already created ecourse.txt file in two ways. First, there is a separate command TYPE to display the contents of a file. Second, you can utilize the same COPY command you used while creating the file. I’ll show you both.
Step 1: Enter the following command on prompt and press Enter
c:\> TYPE ecourse.txt
MS-DOS will display:
ICT Trends runs different eCourse to help candidates of Computer Operator to prepare their exam. It has automated eCourse that runs through emails.
and there will be a new command prompt.
alternately you can use Copy command.
Step 1: Type following command on prompt and press Enter
c:\> COPY ecourse.txt CON
MS-DOS will display:
ICT Trends runs different eCourse to help candidates of Computer Operator to prepare their exam. It has automated eCourse that runs through emails.
1 file(s) copied
c:\>
3. Edit the ecourse.txt file so as to add following line in the file.
Currently and eCourse on Fundamentals and Operating Systems are available. More eCourse will be introduced gradually!
Solution:
Step 1: Type following command on prompt and press enter.
c:\>edit ecourse.txt
Step 2: MS DOS starts Editor application that will display the content of a file. Move the cursor using arrow keys and add following text at the end of the text.
Currently and eCourse on Fundamentals and Operating Systems are available. More eCourse will be introduced gradually!
Step 3: After you’ve down, Press ALT + F to pull down the File menu and press down arrow key to select Save. Press Enter on Save. After that choose File >> Exit similarly, to exit the editor and return to DOS Prompt.
Changing File Attributes
Each file has some attributes or properties that you may want to change some times. The command to change file attributes is ATTRIB.
- A file which is hidden from general file listing such as in DIR has hidden (h) attribute.
- A file which is protected from modification has read only (r) attribute.
- A file which is marked as system file so that Operating System will use it has attribute System (s),
- A file marked for archiving has archive attribute (a)
You can use +attribute to add attribute to a file and -attribute to remove that attribute from files. For example following command makes ecourse.txt file read only:
c:\> attrib +r ecourse.txt
Similarly, the following command will make it hidden and system file
c:\> attrib +s +h ecourse.txt
You can remove the attributes from a file by using -. The following command will remove all the three attributes from the file.
c:\> attrib -h -s -r ecourse.txt
c:\>attrib will display all the file attributes of all the files in current location (c:\).
You can use wildcard characters to group files and change permission to the whole group at once. For example, following command adds system attribute to all the files having .sys as an extension.
c:\>attrib +s *.sys
Click here to read more about ATTRIB command.
Renaming, Moving and Copying Files
Copying is to create a duplicate copy of files. Moving file is to change the location from one directory to another. Renaming files mean to change the name of existing file into new one. MS-DOS offers COPY command to create duplicate copies, MOVE command to transfer location from one directory to another, and REN or RENAME command is used to change the name of a file into new one.
Though these three tasks and the three commands appear completely different, they have a close relation. Moving is to copy the file to a new location and delete the original file. So moving involves copying and deleting. Renaming is to move the file on the same location but with a different name. So renaming involves move operation.
Yet another fact! COPY CON is, in fact, the COPY command with CON as the first parameter. COPY commands take two mandatory parameters- the first one source file (that is to be copied) and the second parameter is the destination (the one to be created). On COPY CON newfile.ext command we used CON (console) as source and newfile.ext as second parameter. So whatever you typed or whatever is there on console is copied onto a file filename.ext.
That’s why, to display the content of a file, you can use TYPE command or alternately use COPY filename.ext CON. Because the source is filename.ext and the destination is the console, it will copy the file on the screen.
All the three commands COPY, MOVE and REN or RENAME takes two compulsory parameters – source and destination.
Click these command names to read more about them:- COPY, MOVE, RENAME, TYPE
Examples:
1. There is a file named ict.txt in IMP directory of D:\DOCS. Change the name of the file into trends.txt.
REN D:\DOCS\IMP\ICT.TXT TRENDS.TXT
or,
RENAME D:\DOCS\IMP\ICT.TXT TRENDS.TXT
2. Move the file trends.txt from IMP directory of D:\DOS into F:\transfer
MOVE D:\DOCS\IMP\TRENDS.TXT F:\TRANSFER
3. Copy trends.txt file in F:\Transfer into the root directory of E drive.
COPY F:\TRANSFER\TRENDS.TXT E:\
4. Copy all the files having .bak extension into a floppy disk
COPY *.BAK A:\
5. Rename all the files having .txt extension into .ext extension
This is not possible with a single command. You’ll need to issue a separate command for each file existing in the source location.
6. Move all the files that begin with “D” and has .doc as extension into pen drive. [given, pen drive is inserted in G drive]
MOVE d*.doc G:\
7. Copy c:\users\user\doc\madan.txt into c:\users\user\doc
This is not possible. There can’t be two files with the same name in the same location.
8. Rename ram.txt file into sita.txt which is in doc subdirectory of user subdirectory of users directory in C drive.
REN c:\users\user\doc\ram.txt sita.txt
9. Copy all the files of a diskette into another diskette.
COPY A:\*.* A:\
10. Move all files of a pen drive into the desktop directory of c:\ict\trends\docs. [Given, pen drive has H drive]
MOVE H:\*.* C:\ICT\TRENDS\DOCS
Working with File Attributes (again!)
A file in DOS has 4 attributes (properties), namely, read only (r), hidden (h), system (s) and archive (a). A file that is finalized and can’t be modified has read only attribute. You need to remove R attribute if you need to make any change on that file.
Hidden files are not listed on general lists like DIR. You can use DIR, [dir command followed by a comma] or DIR/AH [dir command with attribute hidden switch] to list only hidden files. If you no longer want to hide that file, remove the H attribute from file.
System files are meant to be used by operating system or other applications and they have S attribute.
Files that should be included when creating archives have A attribute.
File attributes can be changed by using ATTRIB command. ATTRIB command accepts attribute codes and file specification. You can add attributes to files with + AttribCode such as +h, +r, +s, +a. Similarly you can remove attributes from files using – AttribCode such as -h, -r, -s, -a.
Examples:
1. Make all the files hidden whose name begin with conf.
ATTRIB +h CONF*.*
2. Remove System and Hidden attribute from settings.sys file located in CONF directory of C drive.
ATTRIB -H -S C:\CONF\SETTINGS.SYS
4. Remove hidden attribute but add read only to finalRPT.doc file Reports subdirectory of FirstQtr directory of D drive
ATTRIB -H +R D:\FIRSTQTR\REPORTS\FINALRPT.DOC
Working with Directories
A directory in DOS is table of contents of a disk. A directory contain the information such as file name, file size, modified date/time etc. It can be displayed by using DIR command. A new directory can be created with MD or MKDIR command. Working directory can be changed by using CHDIR or CD command. If there is any empty directory and are not required, delete them using RMDIR or RD command.
Click these command names to read more about them:- DIR, MD, CD, RD
Points to Remember
- POST is a set of routines stored in a computer’s ROM that tests various system components such as RAM, disks, keyboard to see whether they are properly connected and operating.
- In computer programming, routine and subroutine are any sequence of code that is intended to be called and used repeatedly during the execution of a program. This makes the program shorter and easier to write (and also to read when necessary). The main sequence of logic in a program can branch off to a common routine when necessary. When finished, the routine branches back to the next sequential instruction following the instruction that branched to it. A routine may also be useful in more than one program and save other programmers from having to write code than can be shared. [source whatis.com]
- IO.SYS and MSDOS.SYS are the hidden system files of DOS. COMMAND.COM is command interpreter and is not hidden.
- MS DOS is character user interface single user operating system.
- Directory is the table of contents of a disk. It stores the information such as file name, file creation or modified data, file size etc.
- A directory can contain other directories inside it. The inner directory is called subdirectory and the outer one is parent directory. The directory on which you are currently located is default directory. One essential directory in every disk is called root directory.
- You can not delete root directory. Root directory is denoted by a back slas ‘\’.
- A file name in DOS can’t have more than 8 characters and extension 3 characters. You can not uses punctuation marks or spaces in file name except underscore ‘_’.
- Files with extensions .exe, .com and .bat are called executable files and should be used only for a very specific purpose. [Source: Readmore Computer Wiz page 128]
- A dot ‘.’ is a delimiter to separate filename and extension.
- You can’t use the names CON, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, LPT4, PRN, AUX, NUL as file name. These words are reserved on DOS.
- CONFIG.SYS is the file to specify settings of computer such as location of devices, number of files that can be opened simultaneously, size of buffer etc.
- AUTOEXEC.BAT file is used to run some commands automatically every time when computer boots. Setting DOS path and executing programs like scandisk, antivirus are done in autoexec.bat.
- Path is a sequence of directory and subdirectory separated by back slash ‘\’ that tells the location of file specified.
- PATH command tells DOS where to look for executable files when users types it in prompt.
- Wildcard characters are the symbols that stand for a particular meaning. Aestrict ‘*’ means any number of any character. Question mark ‘?’ means any character but only one. Colon ‘:’ means drive. Back slash ‘\’ means path.
- Command is an instruction to a computer that causes an action to be carried out when issued by user.
- Those commands are internal command whose routine is written inside command.com file. There are many more commands which are written not inside command.com file but as a separate file. They are called external commands.
- Internal commands are loaded when booting and resides in memory as long as computer is running.
- External commands are loaded when user issues it and is wiped out from memory after the execution.
- PROMPT command is used to change the MS DOS system prompt. A prompt is an indicator to inform where you can type a new command or whether the computer is ready to accept your commands or not.
- PROMPT $P$G command displays prompt including Path and Greater than symbol, such as, C:\>
- Computer’s system date can be displayed and changed by using DATE command
- Computer’s system time can be displayed and changed by using TIME command
- COPY, TYPE, EDIT, MOVE, REN, DEL are the commands to work with files in DOS.
- COPY command creates a duplicate copy of files. It can be used to copy the contents from console to files and files to console too!
- TYPE command can be used to display the contents of a file.
- EDIT command is used to edit the contents of a file.
- MOVE command can move files from one directory to other directory.
- REN command is used to change the file name.
- DEL commands can be used to remove any unnecessary file.
- DIR, MD, MKDIR CD, CHDIR, RD, RMDIR are the commands to work with directories in DOS
- DIR command displays the directory, MD or MKDIR creates new directories, CD or CHDIR changes the working directory, RD or RMDIR removes any unnecessary empty directories.
- Attributes are the file properties. A file can be read only (r), hidden (h), system (s) or archieve (a) attribute. ATTRIB command is used to add or remove different attributes to a file.
Leave a Reply