A Short Introduction to DOS (This is very similar to command line operations in UNIX/LINUS). See DOS commands for a list of commands that we can use. Remember that we work in a CLI (command line interface) by typing in command and reading the textural response. So lets fire up a DOS window by going to start, click on run… and type in cmd. You should get something like the following although the drive letter (ie F) might be different. It probably will be C:\>
DOS (Disk Operating System)
DOS has been around almost 35+ years. It was created by Bill Gates around 1981 and was sometimes called MS-DOS. He actually started with code written earlier by Seattle Computer Products. The structure of DOS was influenced heavily by UNIX and consequently it has a UNIX command line feel to it, although much simpler.The first PC’s from IBM used this operating system until Windows came out in the mid 80′s. In order to remain compatible with older software Windows kept DOS under the hood so to speak. Now when we run DOS it is usually displayed in a window, as shown above, but could also be displayed full screen if one likes. In this section we will practice a few of the DOS commands withing the window. There are many tutorials on DOS on the Web. Just search google using “DOS tutorials” as your search string. As a further note, there are many versions of DOS (MS-DOS, PC-DOS etc) which appear to be the same but in fact are incompatible.
1. This first practice session uses the commands mkdir, cd, and tree. Lets start by first going to drive C: if you are not already there. Type the command cd C:\ This will move you to drive C and give you the prompt C:\>. When you get this prompt type in the command dir to get a listing of the contents of this directory (the root directory in this case). The following is a partial display of what I generated on my machine. If you desire you can resize the window and move the side bar to make the entire directory visible on your machine.
Each line of the display contains the following
Date of creation/modification , time of creation/modification, type information, size of file, name of file.
If you edit a file in this list, using say notepad (or notepad++), and resave, it will automatically update the modification date and time. Try it. Now pick a directory name, denoted by <DIR> in the listing, say CUDA in my case, and move to this directory by executing the appropriate command, in my case it would be cd CUDA. Now look at this directory using dir. You are now in a sub-directory of the root directory. Move back up to the parent directory using the simple command cd .. Note that the two dots are required since they refer to the parent directory of your present directory, no matter where you are.
The entire set of directories and subdirectories is call the directory heirarchy(or tree). You can move up and down this tree using the appropriate cd commmand. Practice moving around in the tree.
We have complete control over this tree in that we can create new subdirectories and delete file and sub-directories. Go back to the root using the command cd C:\ and create a new subdirectory, TestDir, using the command mkdir TestDir. Go to this directory using cd TestDir and display it using dir. You should see something like the following
Note that it has only two directories. The .. directory as previously mentioned refers to the parent directory and the . directory refers to the present directory. If you execute a cd . you will stay where you are. Hmmm. what do we use this for? As a side note there is a command that will print out the entire dir tree and it is called tree. Go to a directory that has sub-directories and try it out.
Now lets go back to the TestDir and practice creation and deletion of files. No matter where you are and what OS interface you are using you normally use a text editor to create and type in data for a text file. For this course I will assume that a text file and an ASCII file are the same. These are files that contain only pure text, ie characters that can be represented by and ASCII symbol. These files contain only numbers, alphabetic characters, punctuation and special control characters such as carriage returns(CR) and linefeeds(LF). Check here for an example of an ASCII table. Note the binary representation for for each character or control listed in the table. Pay particuler note to the codes for A,B, … and 0,1,…
At the risk of repeating myself it is important to remember that the symbols listed in this table are the ONLY things that are allowed in a text(ASCII) file. Files created by Word, Excel, Powerpoint etc are NOT ASCII files. They are full of control and formatting commands that are not allowed in an ASCII file.
So how do we create a pure ASCII file? There are several ways but the one we will use here is notepad. This little editor can be used in Windows or in DOS. When in DOS just type the command notepad and a new editing window will pop up and allow you to type in text. Make sure that you are in the TestDir and type the command notepad. It will also create a small window that says it Cannot find the file.txt file. Just say Yes and it will create it. Using the editor type in a half a dozen Einstein quotes that you can obtain from here. It is OK to cut and paste. Modify the file by deleting the quotes and numbering the quotes from 1 to 6. Now place Your name and the top of the file getting something like
Save this by clicking on File, then save and finally close the window. Click in your DOS window and execute dir to see if the new file file.txt is indeed listed as shown below.
You can also display the contents of the above file.txt by using the type command. Type in type file.txt and you should see the contents scroll within the window. Now lets make a copy of this file that has a new name say newfile.txt. This is very easy as well. Just use the command copy file.txt newfile.txt. This creates a new file called newfile.txt and copies the data from file.txt into the new file. A dir command will now show both of these files present. You and delete the old file using the command del file.txt. Do this and look at the directory to make sure it is now gone.
For added experience create a new file called smallfile.txt and put into the file the single word Computer. DO NOT place a carriage at the end of the word. Save it. Now create a new file called smallfilcr.txt and put into the editor the single word Computer, With a carriage return at the end. Save it.
List the directory and look closely at the size of these files. Here is what I got.
The size of smallfile.txt is exactly 8 bytes and the size of smallfilecr.txt is two more. What are these two bytes. For and experiment type both of the files. Do you see a difference?
As a final note I guess I should point out that ASCII is almost obsolete. It was developed in the US (American Standard Code for Information Interchange) and consequently can only handle a small alphabet. With the advent of the internet problems with ASCII began to become very clear. Languages like Japanese, Chinese and many others cannot be represented in ASCII. Even the occasional umlaut etc. cannot be represented in pure ASCII. Here is a nice discussion of UTF-8 on Wikipedia.
COOL TRICK: If you are in windows explorer and looking in a specific directory you can immediately pop up a DOS window (AT THAT DIR) by typing SHIFT- Right Click. Then select “open cmd window here”.