Professional Documents
Culture Documents
DOS A
DOS A
What is “DOS”
• The Windows CLI commands are sometimes
referred to as "DOS" commands.
– DOS was the name of the operating system that
predated Windows (it stands for Disk Operating
System).
– The only way to control DOS was to use these
commands
– The commands in the modern Windows Command Line
interface are very similar to the original DOS
commands, but there are some differences and some
completely new commands.
5
• Running programs
– Filename extensions
(eg. .txt .doc .xls)
– executable files (.exe)
– running a program
– windows explorer -
• view | details
• tools | folder options | view
9
Scripting Commands
• for
• if
• pause
• echo <message>
• echo on
• echo off
• @
• shift
11
• notepad
• cmd
• regedit
12
running / executing
• starting a program or DOS command is known as
OR
Case In-sensitive
• DOS commands are case in-sensitive.
• This means that you can type the commands in either UPPER CASE,
lower case OR a mixture of uPpEr AnD lOwEr CaSe.
• For example the following are all equivalent ways of typing the “dir”
command
dir
DIR
dIr
DIr
dIR
14
Type ENTER
• You must press the ENTER key after typing any
DOS command for it to actually do anything.
15
– Any part of a command that must be typed exactly will be shown as regular text. (see
example below)
– Words between “angle brackets” are placeholders which you must fill in when you run
the command.
More conventions
• This presentation will use the following conventions when describing the commands:
– For example the following command is used to get help about the DOS commands.
help [<command name>]
– The description above shows that you can type the word “help” alone or type the word “help”
followed by the name of a specific DOS command.
If you type the word “help” alone you will see a list of all the DOS commands and a short
description of what each command is used for. Example (don’t forget to press the ENTER key):
help
You can also type the word “help” followed by the name of a specific DOS command to get more
extensive help on that particular command. Example (don’t forget to press the ENTER key):
help dir
17
THE
COMMAND PROMPT
WINDOW
18
The prompt
• The "c:\>" in the picture is called the "prompt"
(your prompt may look slightly different, such as "d:\>", "c:\somefolder>" or something similar - we'll explain later).
• The prompt is automatically displayed by the computer.
• You type your commands after the prompt.
• In order for a command you typed to do anything, you must press the "ENTER" key.
• Commands may be entered either in UPPERCASE, lowercase.or MiXeDcAsE
21
THE
HELP
COMMAND
22
help command
• Type "help" follwed by the ENTER key to get a list
of the valid commands
Output of
"help"
command is
very long
and scrolls
of the
screen.
Use the
scrollbar to
see the rest
of the text
25
help <command>
• To get detailed help about a specific command type the word "help" (without the
quotes) followed by the name of the command.
• For example to get detailed help about the "dir" command, type the following:
help dir
Output of
help dir
command
26
| MORE
27
| more
• To view a lot of output, instead of using the scroll bar, you can force
the output of most commands to be displayed one screen at a time.
• Type the command followed by "| more" (without the quotes), for
example:
• The vertical bar symbol (also called a pipe symbol) is located on the
keyboard above the backslash ( \ ) character. On the keyboard it
looks like a vertical line with a break in the middle`
28
• For example, we will learn about both the “dir” and “type”
commands later, both of which can be combined with “|
more”. The following are both legal:
dir | more
type myfile.txt | more (for this to work, there must be a file named
myfile.txt)
"CTRL-C"
(i.e. CONTROL-C)
Stopping programs with Control-C
31
(i.e. Ctrl-c)
• Sometimes DOS commands may "get stuck" and never
complete or take a loooonnnng time to complete.
• This is sometimes refered to as a program that is "hanging"
• To terminate any DOS program or command you can press
the "Cntrl" key and the "c" key at the same time while the
program is running. (try to remember "c" is for "cancel")
• This key sequence is known as "Control-C" or "Ctrl-C“
• For example you can use Ctrl-C to terminate the "more"
program instead of typing "q"
32
BASIC COMMANDS
(DIR, MD, CD, RD)
38
DIR command
• The DIR command shows the contents of a directory (AKA folder).
• This is the same information that you can see in Windows Explorer
• Simply type the word "dir" followed by the ENTER key
• The output of the command is shown on the next slide
40
A line with <DIR> on it indicates a directory name. Line without <DIR> show file names.
41
Switching Drives
• To switch the disk drive that you are working with, type
the letter for the diskdrive followed by a colon ( e.g. d: )
• Don’t leave any spaces between the letter and the colon
• The prompt will change to show the new drive.
The prompt
changes to show
the new drive
name
45
Directory of D:
• The DIR command will now show the contents of the
folder at the top of the D: drive (i.e. the “root” of D: )
files and
directories in
the “root”
directory of
the D: drive
46
• To switch to
any drive by
type the drive
letter followed
by a colon
followed by
ENTER
47
DOS shows
the same files
Windows
and folders as
Explorer
Windows
Explorer does
48
TREE command
• The TREE
command
shows the
DOS
hierarchy
of
directories
• You can
see the
same info
from
Windows
Windows
Explorer
Explorer
50
NAMING
DISK DRIVES, DIRECTORIES
(AKA folders), AND FILES
51
DIR <path>
• To display the contents of a different folder with
DIR, you must specify the name of the directory.
• EXAMPLE: The following shows the contents of
the “accounting” directory that is in the
“schoolWork” directory that is in the root of the D:
drive:
DIR d:\schoolWork\accounting
Example
• To see the contents of the accounting directory type
dir d:\schoolWork\accounting
Contents of
accounting
directory
53
dir d:\schoolWork\accounting
DOS
drive
letters
57
Example explained
• The example on the previous page is repeated here
D:\otherStuff\NTFSDOS3\readme.txt
• On standard keyboards:
– the backslash (\) is
forward slash located directly above
backslash the ENTER key.
– the forward slash (/) is
located next to the shift
key on the right hand
side of the keyboard
backslash in filenames
60
spaces in filenames
• If any folder or filename in a path contains spaces,
you must surround the entire path with quotes
when using it in a DOS command.
• Example
The root
• The top level of any disk drive is called the "root"
of the disk drive.
• The root is indicated by a single backslash ("\")
character. For example:
– the root of the C: drive is C:\
– the root of the A: drive is A:\
– the root of the D: drive is D:\
– etc.
63
DIR /w
• The /w output of
option for “DIR”
the DIR command
command
shows the
output in a
“wide”
format.
• Execute
the
command
by typing
“dir /w”
68
DIR /?
69
DIR /on
70
DIR /o-n
71
DIR /od
72
DIR /o-d
73
MD <directory name>
md entertainment
74
• The syntax is
CD <directory name>
cd entertainment
77
CD to a full path
79
drive letter
<drive letter>:
87
OTHER COMMANDS
92
CLS Command
• Type the CLS command followed by ENTER to
clear the screen.
93
Type
94
TODO
• tree hierarchy – parent, child, root, leaf
• help dir
– options / switches
– optional parts of command
97
• wildcards * and ?
• dir with wildcards
• Files, extensions
• copy
• del vs, rd
• .exe files
• path
• rd
• ren
• set
• cmd /k
98
APPENDICES
99
COMPARING FILES
FC command
104
CONTROL CHARACTERS
106
Control characters
• Control-C is an example of a “control character”
• There are 26 control characters, one for each letter.
• There is no distinction between capital and lowercase
letters: Ctrl-C (capital “C”) is the same as Ctrl-c
(lowercase “c”)
• Some control characters have special meaning. For
example:
– Ctrl-H is another way of typing a backspace character (try it out
in a command window)
– Ctrl-M is another way of typing the ENTER key
(try typing “dir” followed by ctrl-M)
• Sometimes control characters are shown with a ^ character
followed by the letter. For example control-A can be
shown as ^A
107