|
ESSENTIAL Command Line DOS IS DEAD - LONG LIVE THE COMMAND LINE!
Welcome
to the wonderful world of DOS. In DOS's world we don't shove our
operating system around like we do with our mouse & Windows. No, in
DOS we use our keyboard and "chat" with it.
Imagine a conversation with a very gifted three-year old. If
we want to get anywhere, we better learn to communicate with it using a
language that it understands.
But if you can stick with it, learn to enjoy it, don't get too
impatient with it, DOS can be a very important troubleshooting ally.
And who knows, maybe you can join the club of DOS super-heros and save
the world from getting too GUI...
Getting About At the Command Line
Basics
Command line Commands are issued from the command prompt. They consist of "reserved words" (the actual command name) plus any parameters or switches.
We may type the commands, parameters & switches in UPPER, lower or
MiXeD cases. Although not always mandatory, it is best to separate
commands, parameters & switches with spaces.
Command: These are the actual "reserved words" – words that the command interperater used in its lexicon. Commands may be internal (they are placed into memory when the file COMMAND.COM is loaded), or external (they are actual "files" on the disk).
Parameter:
Information typed after a command that specifies what the command
should act on. This gives the command some data to work with, sort of
like an "argument" in an Excel function.
Switch: Generally a switch consists of a forward slash (/) followed by one of more numbers or letters. A switch modifies the way DOS carries out a command.
Example: |
DIR |
C:\Windows |
/w |
In nerd: |
command |
parameter |
switch |
In English |
do this |
to this |
in this manner |
A VERY helpful
switch in later versions of the command line is the /? switch! This
switch tells you which switches and kinds of parameters can be used
with the command.
If the command line doesn’t understand what you want it to do, it replies with: "Bad command or filename…" OR " '...' is not recognized as an internal or external command, operable program or batch file."
DCommand prompt:
The command interpreter can let us know what drive & directory
we are in by showing this current "path" in the prompt. If you are
on the C: drive and in the Windows directory the prompt might look
like this: C:\Windows>
If we move back to the directory that contains the Windows directory (called the root directory) the prompt would look like this: C:\>
Changing drives: Oftentimes we need to tell the command
interpreter to "look at" a different drive (or device). To change
drives, type in the letter of the drive you want to change to, a colon,
and press the enter key. Do this with a formatted disk in floppy A:
Type a: <press the enter key>
This would tell the system to change to the floppy drive A. The prompt would look like this: A:\> To change back to C: type: c: <press the enter key>
DOSKEY
Easy access to
previously issued command line commands! Use the up and down arrow
keys. This feature is built into the command interpreter in Win2K and
up.
Or you can usually use F3 to access the very last command…
File and directory names - Very A+
Legal Characters in Filename:
A - Z 0 - 9 $ # & @ ! ( ) - { } ' ` _ ~
Illegal:
| < >
\ ^ + = ? / [ ] " ; : , * plus control characters and the space
WILDCARDS
Many commands associated with file handling (eg. ATTRIB, COPY, DEL, DELTREE, etc.) accept the use of the "wildcards" (* and ?). In general terms, * refers to multiple characters and ? refers to a single character in a file or directory name.
Wildcard |
Typical interpretation |
*.* |
All files with all extensions. |
*letter*.* |
All files with "letter" anywhere in its name. |
*smith.* |
All files with names ending with "smith" (or "Smith") |
Test?.txt |
All files named "test" + one character and with txt extensions (eg test1.txt, but not test-a.txt nor test.txt) |
SHORTCUTS
A number of commands recognize certain shortcuts when navigating between directories. The best known of these are:
. |
to refer to the current directory |
.. |
to refer to the parent directory |
\ |
to refer to the root directory of the current drive. |
Drive: |
to refer to the current directory on drive |
It is very
A+ to know
how to get to a session in the various flavors of Windows:
- Win95 and Win98 – Start / Programs / MS DOS Prompt
- Windows ME, NT, 2K and XP – Start / Programs / Accessories / Command Prompt
- In any of them – Start / Run / <type> command
- In NT, 2K or XP – Start / Run / <type> cmd (true 32-bit DOS subsystem)
DOS - Disk Operating System
MSDOS is a single user, single tasking, 16-bit operating system.
- Single
user
means only one person
uses the computer at a time.
- Single
tasking
means that it essentially
only runs one application program at a time, and has no inherent
support for running more than one application program simultaneously.
- 16-bit
means the OS can deal
with data in 16-bit chunks.
- Standalone Versions 1.00 - 6.22
- Version 7x comes (free) with Windows 9x
DOS Boot process
- (post POST & bootstrap loader) - Very
A+
IO.SYS
- a DOS version of BIOS-type procedures. It has default device drivers
for things like:
Console display and keyboard
Parallel communications - printer
Serial communications – modems, mice and printers
MSDOS.SYS
- disk and device handling programs (the kernel
of DOS): In DOS versions < 7.0 it supports things like:
File management
Memory management below 1MB
Execution of other programs
CONFIG.SYS
(optional - configures drivers that IO.SYS
leaves out)
User can change
Configures hardware
Memory management drivers go here
COMMAND.COM
- internal
DOS commands
AUTOEXEC.BAT
(optional - sets up the DOS environment)
User can change
Configures environment
TSR (terminate and stay resident)
Fun With the Command Line – This assumes DOS Version 7
The DIR command and Help
C:>dir /? <enter>
Nothin’ but DIR
– getting acquainted with DOS syntax
Change the Directory display
|
Normal
|
DIR
|
|
Help
|
DIR /?
|
|
Screen-at-a-time
|
DIR /P
|
|
Wide display
– less data
|
DIR /W
|
|
Both
|
DIR /W
/P
|
A personal favorite
|
Show current
directory AND subdirectories
Can be combined with file names to FIND specific files.
|
DIR /S
DIR ufoundme.txt /S
|
Change Sort Order
|
Normal
|
DIR
|
|
By size
Small to large
Large to small
|
DIR /OS
DIR /O-S
|
|
By date
|
DIR /OD
|
|
|
|
|
By date with
a pause
True geek way
|
DIR /OD
/P
<OR>
DIR /OD | MORE
|
Show files with
specific attributes
|
Normal
|
DIR
|
|
Everything!
|
DIR /A
|
|
Just hidden
|
DIR /AH
(Or /AA /AR /AS /AD)
|
|
Hidden and system
|
DIR /AHS
|
|
Hidden NOT system
|
DIR /AH-S
|
Now that we have
mastered how DOS works using the DIR command, let’s move on to some other
commands…
Using FORMAT and SYS
|
Format a DISK
(or volume)
|
FORMAT
C:
DIR C: /A
|
|
Format a DISK
real fast…
Note that you CANNOT quick format right after you have modified
partitions with FDISK, or on a disk that has not been formatted
with DOS already.
|
FORMAT
C: /Q
|
|
Format a DISK
and make it bootable
|
FORMAT
C: /S
DIR C: /A
|
|
Format a DISK
and give it a name
|
FORMAT
C: /V:TECH
|
|
Copy system
files only
|
SYS C:
|
|
Do it all…
Only for the brave…a format with no questions asked. May use /s
|
FORMAT
C: /S /V:TECH /Q
FORMAT C: /AUTOTEST |
Using PATH'rudy' is not recognized as an internal or external command, operable program or batch file.
The path command sets the PATH that DOS will search through for executable
files. By default DOS checks ONLY the current directory and gives up!
In your work in this class, if you see this message "Bad command
or filename" when issuing a DOS command, suspect a PATH problem.
The PATH can be set/modified in the AUTOEXEC.BAT file or
from the command prompt
|
See current
PATH
|
PATH
|
|
Test…
Now fix'rudy' is not recognized as an internal or external command, operable program or batch file.
|
MEM
SET PATH=\command
|
|
Give it a test
|
MEM
|
Using ATTRIB
|
View attributes
of files in current directory
Getting too much info?
|
ATTRIB
ATTRIB | MORE
|
|
Hide a file
|
ATTRIB
1.txt +H
|
|
Unhide a file
|
ATTRIB
1.txt -H
|
|
Unhide a system
file:
Try this first –
Here is the way
|
ATTRIB IO.SYS -H
ATTRIB IO.SYS -S
ATTRIB IO.SYS -H -S
|
|
DO NOT (unless
you mean it)
|
ATTRIB
+H <note no file name>
|
Using VER
|
View DOS/Windows
version
|
VER
|
Using Copy / Move
|
Syntax
|
COPY
source destination
|
|
Normal
|
COPY
A:\1.txt A:\stuff
Or, to be less explicit…
COPY 1.txt \stuff
|
|
Copy and rename
|
COPY
2.txt \stuff\newname.txt
|
|
Copy with wildcard
|
COPY
*.bak C:\
|
|
Copy from the
console to a file. A walk on the wild side…
|
COPY
CON myfile.txt <enter>
Some text goes here…
<press F6>
^z
|
Using TYPE
|
View the contents
of a text file
|
TYPE myfile.txt
TYPE COMMAND.COM
|
Using EDIT
|
Edit a text
file
|
EDIT
|
|
Run EDIT with
a file
|
EDIT
myfile.txt
EDIT
COMMAND.COM
|
Using XCOPY
|
If you want
to copy whole directories of stuff then XCOPY is your tool.
Go into your "STUFF" directory
|
XCOPY
source destination
|
|
Will copy stuff
directory to root
Without explicitly specifying the \stuff directory,
XCOPY will copy the contents of stuff to the root.
|
XCOPY
inside \inside /e
"Does inside represent a file name or directory name on the
target? Answer "D""
|
| If
you want to copy the Win98 directory from the CD in D: to the hard
drive at C: |
XCOPY
D:\WIN98 C:\WIN98 |
|
If you want
to take everything and you are using DOS7 (in a session)
then:
|
XCOPY
source destination /R /I /C /H /K /E /Y
|
Potpourri - Rename
/ Delete files / Make and Remove directories / move around
|
Change directory
|
CD stuff
CD ..
CD \stuff\inside
CD ..
|
|
Rename
|
REN 6.txt
6.bak
RENAME 6.bak 6.txt
|
|
Delete
|
DEL \stuff\newname.txt
ERASE \stuff\1.txt
|
|
Make a directory
|
MD APLUS
MKDIR BPLUS
MD TESTME
<Now copy all .bak files to this directory>
|
|
Remove an empty
Directory
|
RD APLUS
RMDIR BPLUS
RD TESTME
|
|
Remove a directory
and EVERYTHING inside it
|
DELTREE
TESTME
|
Using SCANDISK
and DEFRAG
|
Scan a disk
for errors (done before a defrag)
Crosslinked = a cluster assigned to two different files
Lost clusters = a file whose clusters aren’t associated with
it
|
SCANDISK
|
|
Or do it the
old way…
Check and display status of the disk. Will create those .CHK files
in your root (done before a defrag)
Use SCANDISK when available!
|
CHKDSK
[/F to fix]
|
Using SETVER –
fixes Incorrect DOS version message
|
SETVER is installed as
the first line of config.sys
|
DEVICE=\SETVER.EXE
|
|
You may view the current
SETVER table
Try to run the DOS 6.20
TREE command that is in your COMMAND directory. You should get,
"Incorrect DOS Version"
Enter a program into
the SETVER table. You may add the program to the SETVER table like
this:
SETVER PROGNAME.ext n.nn
You will need to reboot.
Should work like a champ now. How do you like it?
|
SETVER
TREE
SETVER TREE.COM 6.20
TREE
|
EOE – End of exercise
IT’S
ALL ABOUT YOUR MEMORY! – Probably fallen off the edge of A+
MS-DOS And Memory
DOS can only "see" the first megabyte - 1024K - of RAM. This
is the memory that DOS can directly manage without the use of additional
memory managers.
MEMORY
CLASSIFICATIONS
Conventional Memory
The first 640K memory storage locations (bytes) of your PC. Used traditionally
for data and programs.
Upper Memory - UMA
The next 384K memory storage locations (bytes) of your PC. Used traditionally
by hardware / BIOS.
Expanded Memory - EMS
A technique for increasing memory in DOS PC’s. It allows DOS to work with
up to 32MB of extra memory by switching segments of EMS memory into upper
memory
Extended Memory - XMS
In Intel 286’s and up, it is standard memory above one megabyte. Extended
memory is used directly by Windows.
High Memory - HMAThe first 64K of memory from 1024K to 1088K which
can be accessed by DOS. It is managed by the HIMEM driver.
|
DOS
MEMORY Map
|
|
Anything
above 1MB
|
Extended
(XMS)
|
<
up tp 32MB Expanded (EMS)
|
|
1st
64K after 1MB
|
High
|
|
640K-1024K
|
Upper
|
|
0-640K - 1
|
Conventional
|
|
|
UPPER
MEMORY Map
|
|
640K
- 1000K
|
BIOS
ROM
|
F0000-FFFFF
|
|
Network
Card ROM
EMS Page Frame
|
D8000-DF000
D0000-DFFFF
|
|
VGA
Video ROM
|
C0000-CFFFF
|
|
Video
RAM
|
A0000-BFFFF
|
Using MS-DOS Memory
Managers – Very
A+
To
use your computer’s extended
memory, expanded
memory, high
memory or upper
memory area, your CONFIG.SYS file must contain a command that loads
a memory manager. MS-DOS includes the following memory managers:
- HIMEM.sys,
which provides access to extended
memory
and high
memory
- EMM386.exe,
which provides access to the upper
memory
area and uses extended memory
to simulate
expanded memory.
MS-DOS does not
include an expanded-memory manager for physical
expanded memory,
since each expanded-memory board requires it’s own memory manager.
More exercising…
Modifying
Boot Parameters
I will explain what
each line does. Add an extra line under each line for your comments. Begin
each new comment line with a ; or a REM
EDIT CONFIG.SYS
;edited by rudy
device=himem.sys
device=emm386.exe noems
dos=umb,high
lastdrive=m
files=15
device=oakcdrom.sys /d:TEACHME
EDIT AUTOEXEC.BAT
REM edited by rudy
@echo off
set path=\command
doskey
mscdex /d:TEACHME
smartdrv
Using MEM
|
Shows DOS memory
organization
|
MEM
|
|
Classify memory
Pause the display
|
MEM /C
MEM /C /P
|
|
Really, really
classify memory…
|
MEM /D
/P
|
|
|
|
|
Modify your
config
and autoexec
files:
Change
device to devicehigh
Change
doskey
to lh doskey
Change mscdex to lh mscdex
Note that by
default, SMARTDRV will move itself to upper memory if available.
|
MEM /C
/P
|
DOS < 7 also provides
us with a tool to view memory and other resources. This tool is called
Microsoft Diagnostics (MSD). XP Command Line Tools
rd /s (instead of deltree)
chkdsk /f
diskpart diskpart> select disk 0 detail disk list disk list partition list volume
tasklist tasklist /svc taskkill
sc queryex sc stop themes sc start themes sc queryex | findstr /i “themes”
Windows Management Instrumentation Console wmic /? wmic cpu > c.txt notepad c.txt
Try some of your own… BIOS, BOOTCONFIG, DESKTOP
wmic process WHERE (Description="explorer.exe") wmic qfe list full | more
WMIC /NAMESPACE:\\root\wmi PATH MSStorageDriver_FailurePredictStatus
netsh diag show test netsh diag gui
If you have downloaded the XP support tools then: netdiag /v > c.txt notepad c.txt
|