Tuesday, May 11, 2010

EXERCISE: 1 MS-DOS as an Operating System

An operating system consists of one or more programs that control the allocation and usage of hardware and software resources and functions as an interface between the user, application programs, and the hardware.
Microsoft Corp. MS-DOS 1.0 came out in 1981. Since then there have been a number of upgraded versions, the last being Version 6 Release 22 (v6.22). Versions are upward compatible meaning that commands which worked in earlier versions will work in later versions. The command line MS-DOS has been superseded by the more powerful GUI Windows operating system. However under Window you can run a “version” of MS-DOS in a Command Prompt window. This is useful for executing MS-DOS legacy software.
Unlike GUI (Graphical User Interface) Operating Systems like Windows, MS-DOS has a command-line interface. That is commands are typed at the so-called MS-DOS prompt
C:\Temp>
where C: identifies the default drive and\DOS identifies the default path. The top level directory, identified by a single \ as in C:\> is called the root directory.

Moving Between Directories

To maneuver your way around Directories use the CD (think of Change Directory to easily remember it) command. The CD.. command is used to back your way down a certain path. Now click on "Command Prompt" on the Windows Taskbar to display the Command Prompt which should currently display "C:\Documents and Settings\UserName>". Type CD.. and press "Enter". Now the displayed path should be "C:\Documents and Settings>". Type CD.. again which should take you right to the root of the drive and it should display like follow: "C:\>".
To work your way up the path again to the same position you started of, use the CD command as follow: CD Documents and Settings which will land you in "C:\Documents and Settings>". Then type CD UserName (Remember to substitute UserName for what it is on your system) which will land you in "C:\Documents and Settings\UserName>".
To go right down to the root of the drive from the current subdirectory use the CD command as follow: CD\
If you used above CD\ command you should now be in the root of C: (C Drive). Just one last thing about the CD command, when you work your way up a path using the CD command you do not have to take it one directory at a time. I may be done as follow: CD Documents and Settings\UserName to land you right in the subdirectory.
CD.. (Work your way down a path)
CD\ (Take you right to the root of the drive)
CD NameOfDirectory\NameOfSubDirectory (Work your way up a path)
CD (When used on its own it just displays the current path)


Switching Between Drives

This is very easy as all you have to do at the Command Prompt is type the following and press "Enter"
D: (After typing D: press the "Enter" key to switch to D Drive)
E: (After typing E: press the "Enter" key to switch to E Drive)
F: (After typing F: press the "Enter" key to switch to F Drive)
C: (After typing C: press the "Enter" key to switch back to C Drive)



Clearing the Screen

You probably now have a DOS screen full of typing and displayed information. To clear it all just type CLS at the Command Prompt and press "Enter".

Listing Directories (Folders) and Files

Type Dir at the Command Prompt and press "Enter" to display a listing of the Directories and Files contained in the current Directory.
There are various options to use with the Dir command:
Dir /p (Pause the display after every screen - Press Enter to view next screen)


Dir /w (Displays in Wide Format. Date and time file created not displayed)

Dir /aa (Displays only files ready for archiving)

Dir /ah (Displays only hidden files)

Dir /ar (Displays only read-only files)

Dir /as (Displays only system files)

Dir /a-a (Displays all files except files ready for archiving)

Dir /a-h (Displays all files except hidden files)

Dir /a-r (Displays all files except read-only files)

Dir /a-s (Displays all files except system files)



Creating Directories (Folders)

If you are not currently in C: (C Drive) type C: and press the "Enter" key on the keyboard to take you to C Drive. Also if not currently in the root of C Drive (which will be displayed like this: "C:\>") type CD\ and press "Enter" to take you to the root of the drive. Now type MD MainDir and press "Enter" to create the in the root of C:\ the MainDir directory. The MD command is used to create directories. To remember it easier thinks of it as Make Directory.
Type the Dir /p command and press "Enter" to see if you can notice the MainDir directory. Note that directories will always be indicated by right after the date and time fields. Then type cd MainDir to change current directory to C:>\MainDir>. (Note that you can use cd or CD as the case in which you type the commands does not matter).
Once inside the MainDir directory type md SubDir1 and press "Enter" to create a subdirectory called SubDir1 inside the MainDir parent directory. Follow it up by typing md SubDir2 to create a 2nd subdirectory inside the MainDir parent directory.
Use the dir command to display a listing of your 2 subdirectories. I will get a little bit later to the issue of deleting directories as we are first going to use these subdirectories that have just been created in some exercises.



Editing Text Files

At the command prompt type Edit and press "Enter". The MS-DOS Editor will now display in the Command Prompt Window. Type some text inside the editor window. Now click on "File" and then on "Save". Before we go any further first note the path indication just below the "File Name" label. It is indicating the current directory and path to it which should now be "C:\MainDir". In the "Directories" box, double-click on "SubDir1". Note that the path should now be "C:\MainDir\SubDir1". Click on the first dot in the field next to the "File Name" label or use the Tab key until the cursor flickers in this field. Now type File1.txt in this field and click on OK.
When ready click on "File" and then click on "New". Enter some text in the editor window and click on "File" and then on "Save". Notice the path just beneath the "File Name" label which should now be "C:\MainDir\SubDir1". However, we want to save our current information in the editor window into a new file and also in the "SubDir2" subdirectory instead of the "SubDir1" directory. In the box below "Directories" there should be 2 dots right at the top. Double click on ".." and notice that the path changed to "C:\MainDir". this look somehow familiar? Yes remember the CD.. command that is used to work your way backward down a path to the parent directory. It is fulfilling the same function in this "Directories" box. Next double-click on "SubDir2" and note that the path should now be "C:\MainDir\SubDir2". Use the Tab key on the keyboard until the cursor flickers in the field next to "File Name". Type File2.txt in this field and click on OK.


For the purpose of demonstrating some other commands we need to create another file. So here we go again. In the MS-DOS Editor click on "File" and then on "New". Type some text in this editor window and save it as "File3.dat" (Notice the different extension we use this time - ".dat" instead of ".txt") in "C:\MainDir\SubDir2". If you get stuck just look back at the steps in the previous paragraph. Also make double sure that it is saved in the "SubDir2" directory as we need it in that location for some of the exercises that will follow.
Now click on "File" and the on "Exit" to exit the MS-DOS Editor. You should be now backing at the MS-DOS Command Prompt. Should you need to edit any of the text in the files you've just created use the Edit command. When the MS-DOS Editor displays, click on "File" and then on "Open". Use the "Directories" box to work your way up or down paths or to change drives. All files that are listed in the current directory will be listed in the "Files" box. To open a file double-clicks on it.

Just one last thing I would like to bring under your attention while we are still busy with the Edit command. If still in the MS-DOS Editor click on "File" and then on "Exit" to exit the MS-DOS Editor. Make use of the CD command to set the Command Prompt to "C:\MainDir\SubDir2>" if it is not the current directory. Type Edit at the Command Prompt and press the "Enter" key. Click on "File" and then on "Open". In the file name notice the following characters: *.* which is called "wild cards". What it basically means is the any file name with any file extension will be listed in the "Files" box that is in the current directory. Change the *.* to *.dat and press "Enter". Notice that only files with the .dat extension will be listed. Alternatively change it to *.txt and only files with the .txt extension will be listed. We will get back to this "wild cards" at a later stage when deleting or copying files.

Followers