Sie sind auf Seite 1von 7

DOS primer

A:\>dir Volume in drive A has no label. Volume Serial Number is 1234-5678 Directory of A:\ TEST AUTOEXEC CONFIG HIMEM EMM386 COMMAND <DIR> BAT 391 SYS 63 SYS 33,447 EXE 126,695 COM 96,370 5 file(s) 1 directories 01-01-99 01:02 12-05-99 14:40 12-05-99 14:45 05-05-99 22:22 05-05-99 22:22 05-05-99 22:22 256,966 bytes 1,200,698 bytes free

A:\>dir /p

You can also specify the parameter "/ad". It shows only directories, no files. For a more detailed explanation of why it shows only directories, see section 7, "File attributes". Note that dir accepts tons of other parameters. All DOS commands will provide an overview of the parameters they accept if you invoke them with the "/?" parameter, e.g.
A:\>dir /?

5. Directories 5.1 Changing the directory If you are in A:\> and would like to see the content of the subdirectory TEST, you must first change into that directory. This is done using the "cd" command ("cd" stands for "change directory"). It must be followed by the name of the directory:
A:\>cd test A:\TEST>_

Please note that DOS is NOT case-sensitive, e.g. it doesn't matter which combination of majuscules and minuscules you use. TEST is equivalent to test which is equivalent to tEsT, which is equivalent to TEst, etc. You may now for example use the dir command to inspect the content of the directory. To go back to the directory you came from, type in "cd..". This will tell DOS to go back one step in the directory

hierarchy:
A:\TEST>cd.. A:\>_

You can also specify the path of a directory (the path is the full name of the directory including the drive letter):
A:\TEST>cd a:\hello A:\HELLO>_

5.2 Creating and deleting directories Use the "md" ("make directory") command followed by a name to create a directory, e.g.
A:\>md test

Note that file names and directory names must follow certain rules:

They must contain no more than 8 characters, optionally followed by a dot and an extension of no more than 3 characters. The following characters are NOT allowed because they have a special meaning: ? * / \ : < > | The following names are not allowed because they have a special meaning: nul, con, prn They are not case-sensitive

To delete a directory, use the "rd" ("remove directory") command:


A:\>rd test

Please note that for this work to work, the directory must be empty, e.g. it must not contain any files or subdirectories! Of course, you cannot delete the directory you are in, so you first have to change to another directory. If you want to delete a directory including its subdirectories and files, use the "deltree" program. (It may or may not be on your boot disk):
A:\>deltree test

Caution! Deltree is extremely destructive! It will ask you for confirmation before it proceeds. Think twice before you use it!

6. File management 6.1 Deleting files

A file can be deleted using the "del" command:


A:\>del letter.txt

Note that DOS will not ask for confirmation before it deletes the file! If you want to delete all files in a directory, use so-called "wildcards":
A:\>del *.*

This will delete all files in the current directory. DOS will ask for confirmation first, but only once for all files! It will not ask you to confirm the deletion of each file! The asterisk * stands for a sequence of characters of arbitrary length; you can also use the ? character which stands only for one character. For example, the following commands deletes all files that start with "letter" followed by any character, and regardless of their extension:
A:\>del letter?.*

Note that most other DOS commands accept wildcards as well! 6.2 Copying files Copying files is done using the "copy" command:
A:\>copy letter.txt c:\document

The first parameter is the source, the second parameter is the destination. If you omit the destination, then DOS considers the current directory to be the destination:
A:\>copy a:\test\letter.txt

This copies the file letter.txt from the directory A:\test to the current directory, which is A:\ . If you want to move a file (e.g. copying a file and then deleting the source file), use the "move" program. It may or may not be on your boot disk. Note that you must always specify a destination. Except for this particularity, the syntax is the same for copying and moving. 6.3 Renaming a file You may change the name of a file using the "ren" command. Note that there cannot be two or more files of the same name in the same directory! Of course, the new filename must follow the rules mentioned in section 5.2.
A:\>ren oldname.txt newname.txt

6.4 Viewing and modifying a file

The "type" command allows you to view a file that contains readable content (for example text files). Depending on how many lines the file consists of, you will observe the same phenomenon as with the dir command mentioned above: the screen will scroll quickly and you will see only the last lines of the file. However, the "type" command does not know the "/p" parameter. You must combine the "type" command with the "more" command. I will just present the syntax to you, you do not need to know how it works, you just need to know that it works:
A:\>type autoexec.bat | more

To modify a text file, you can use the DOS editor. Its name is edit.com (type "edit" at the prompt). Just run it; it has a user interface which should not pose problems to you as a Windows user. Note that if you don't have a mouse or your boot disk offers no mouse support, you can activate the menu bar by pressing the "Alt" key on your keyboard. You can then navigate through the menus using the arrow keys and the Enter key. To leave the menu bar, press Esc. You can highlight text by holding down the shift key and using the arrow keys.

7. File attributes Every file and directory has certain attributes that characterize it. For example, attributes determine whether a file may be modified ("read-only" attribute), whether it is shown by the "dir" command ("hidden" attribute) or whether it is a system file ("system" attribute). There is also an "archive" attribute but it matters only when you are creating back-ups so we are not going to discuss it here. Finally there is the "directory" attribute. It marks a directory - there is nothing magical about it. Regular file Read-only Hidden System Shown by "dir" Yes Yes No No Can be modified Yes No Yes Yes Can be deleted Yes No No No Can be copied Yes Yes No Yes Can be renamed Yes Yes No Yes Note that the "no" is stronger than the "yes". For example, a read-only file will be shown by dir however, if it's read-only and hidden, then it will not be displayed because of the hidden attribute. The "attrib" program enables you to set or delete attributes. If you execute it without any parameter, it displays the current attributes of all files in the current directory:
C:\test>attrib A S SYSTEM.TXT A H HIDDEN.TXT A R READONLY.TXT A SHR ALL.TXT A NONE.TXT

The "A" stands for the "archive" attribute; again, you may ignore it. Remember that you can use

"more" if the screen scrolls. See section 6.4 To set/remove an attribute, specify a + or - followed by the attribute letter and the filename or wildcards:
A:\>attrib +r test.txt A:\>attrib +h -r letter.txt A:\>attrib +h -r + s *.dat

Note that you can tell the dir command to display only files that have a certain attribute. Use the /a parameter directly followed by the letter that stands for the attribute you want to filter out, for example
A:\>dir /ah

displays only hidden files.

8. Other DOS commands 8.1 Path When you enter a command, the command interpreter first verifies whether it knows the command. If so, it executes it. If it does not recognize the command, it searches for a file whose name consists of what you entered plus the extension .com (of course it won't add ".com" if the string you entered already ends with ".com"). If there is still no such file, it searches for a file with the extension .exe, and then .bat. If it can't find any file, it displays the "Bad command or file name" error message. If, however, there is such a file, it launches it. But where does the command interpreter search for these files? If you specify the directoy of the file you want to launch, it checks whether the file exists in that directory. If you do not specify the path of the file, it searches in the current directory, and then in a list of directories known as the "path". It determines where command.com should search for executable files. You can display its current content by typing "path" at the DOS prompt:
A:\>path PATH=A:\;A:\TEST A:\>

Note that the first directory will be searched first, then the second, etc. You can set the path by entering the "path" command followed by a list of directories separated by semi-colons. To append a directory to the existing path, use the "command" followed by the word "path" between percentage signs ("%") followed by a semi-colon and then the directory.
A:\>path

PATH=A:\;A:\TEST A:\>path a:\hello A:\>path PATH=A:\HELLO A:\>path %path%;a:\letters A:\>path PATH=A:\HELLO;A:\LETTERS A:\>

8.2 Memory Use the "mem" program to display the amount of used and free memory. mem /c displays a list of loaded modules and the amount of memory they consume. Use the "/p" parameter to cause mem to wait after it has filled a screen (it works exactly the same as with the "dir" command) Please note that mem is a program. It may or may not be on your boot disk. 8.2 Time and date Enter "time" to display the current time. You may enter a new time or simply press Enter if you don't want to enter a new time. The same applies to "date". 8.3 Clearing the screen Type in "cls" to clear the screen.

9. Config.sys, autoexec.bat, io.sys and msdos.sys The two text files autoexec.bat and config.sys should be on your boot disk. They serve special purposes. 9.1 Config.sys This file loads certain device drivers to memory and may contain some configuration information for DOS. A line starting with "device" or "devicehigh" loads a device driver. There is a slight difference between the two, but you don't need to care about it - from our point of view, they do the same. If in doubt, use "device". The "REM" ("remark") command is of paramount importance. DOS ignores a line starting with REM. This allows you to temporarily disable a device driver without having to delete the corresponding line (for the changes to take effect, you have to reboot because DOS reads the contents of config.sys only on start-up). Of course, you may use a line starting with REM to insert

comments. 9.2 Autoexec.bat Autoexec.bat is a "batch" file. A batch file contains a batch of DOS commands that are executed in succession. Batch files come in handy when you often have to carry out the same task. Autoexec.bat is executed on start-up. It may specify the keyboard layout for your country, run a certain program, display a welcome message, things like that. Of course, you may edit autoexec.bat as well. It also knows the REM command (see above). 9.3 Io.sys and msdos.sys These are extremely important system files. Basically, io.sys is DOS. Command.com is just a user interface to io.sys. Msdos.sys is also part of DOS in older DOS versions. In recent DOS versions, it is an editable text file, but you really shouldn't bother with either of these files. They are usually hidden and must not be deleted under any circumstances!! They must be in the root directory of the disk!

Claymania Creations 2001 - 2009. All rights reserved.


Updated: June 4, 2001

Das könnte Ihnen auch gefallen