8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
1/39
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
2/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
OverviewIn this chapter, you will learn to
Explain the operation of the command-line interface
Execute fundamental commands from thecommand line
Manipulate files and folders from the command line
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
3/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Historical/Conceptual
IBM invented the PC in the late 70s but neededan operating system
Digital Research had an OS but turned them downIBM went to a small company (Bill Gates at
Microsoft) that had created BASICMicrosoft had never written an OS but acceptedthe challenge
Gates found an OS called Quick-and-Dirty-Operating-System (QDOS) and purchased it from the person who
wrote itMicrosoft released it as MS-DOS V 1.1 (Microsoft DiskOperating System)MS-DOS 6.22 ultimately released in 1994DOS used a command-line interface
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
4/39
Deciphering the Command-LineInterface
IT Technician
CompTIA A+Technician
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
5/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Command-Line Interface (CLI)
How does a command-line interface work?Begins with a prompt indicating the computer is readyto do something
Type in a command and press ENTER
The command is executed
A new prompt is displayed ready for the next
commandCLI executes commands like the Windows GUI
In CLI, type the command and press ENTERIn GUI, point and click to execute commands
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
6/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Accessing the Command Line
In Windows 2000 use the Run dialog boxStart | RunType cmd
You may also access the command line throughthe Start | All Programs menu
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
7/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
The Command Prompt
The command prompt is always focused on aspecific folder
Any commands operate on the files and folders inthe folder in which you are focusedYou must first focus on the drive and folder whereyou want to work
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
8/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Filenames and File Formats
Each program or piece of data is stored as a fileon the driveFilenames have two parts
FilenameIn DOS, up to 8 characters long
ExtensionIn DOS, up to 3 characters longOptional
The filename and extension are separated by adot
Called the 8.3 naming systemThese characters may not be used/ \ [ ] | + = ; , * ?
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
9/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Filenames and Formats
Windows does not restrict the filename to 8.3(can be up 255 characters)
To be backward-compatible with DOS you need tofollow the 8.3 standardWindows creates two filenames for every file toensure backward-compatibility
The extension tells the computer the type of file.exe, .doc, .xls
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
10/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
File Formats
All files written in binary format
American Standard Code for Information
Interchange (ASCII) used for textUniversal file formatDefines 256 8-bit characters
UnicodeUses 16-bit code to cover every character for themost common languages
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
11/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
ASCII Character Chart
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
12/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Drives and Folders
At boot, Windows assigns partitions and a driveletter
Floppy drives are usually assigned A: or B:Hard drive partitions may be assigned C: to Z:CD-ROM drives are named after hard drives
Windows uses a hierarchical directory tree
Files are put into groups called foldersIn DOS we call folders directoriesThe root directory is at the beginning of thehierarchical structure with folders underneath
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
13/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Folders and Files
Folders and files must be uniqueCant be the same name in the same folder
C:\ represents the root directory of C
To describe a subfolder, add the name of thefolder
C:\TEST
The location of a file is called the pathThe path of C:\test\file.txt is C:\test
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
14/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Directory Tree
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
15/39
Mastering FundamentalCommands
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
16/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Structure: Syntax and Switches
The command line requires the exact syntax foreach command
Type the name of the command and desired orallowed switches
Switches modify the behavior of the command
Multiple switches may be allowable
DIR /W /PDisplays the directory in wide mode and one page
at a time
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
17/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Help
Help with any command is readily available in one ofthree waysHELP gives a one-line description of each commandHELP command gives specific help for the command
Command /? gives specific help for the command
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
18/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
DIR Command
The DIR command lists the contents of aparticular directory
The DIR/W command lists only the filenames
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
19/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
DIR Command Switches
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
20/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Directories: CD Command
The CD (or CHDIR) command is used to changethe focus to a different directory
The CD\ command is used to return to the rootdirectory
CD .. Goes up one directory
To switch between drives, type the drive letterfollowed by a colon
C:D:
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
21/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Making and Removing Directories
The MD (or MKDIR) command is used forcreating a directory
The DEL command is used for deleting files, andthe RD (RMDIR) command is used for deletingdirectories and subdirectories
The DELTREE command is used for deletingdirectories containing files and subdirectories
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
22/39 2007 The McGraw-Hill Companies, Inc. All rights reserved
Running a ProgramTo run a program:
Change the DOS focus to the directory where theprogram is stored
CD C:\Program Files\My Program
Type the filename with or without its extension andpress ENTER
Setup.exe
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
23/39
Working with Files
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
24/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Working with Files Attributes (H, R, S, A) are special values assignedto a file
Hidden : hides the fileRead-only : protects a filefrom being deleted or modifiedSystem : identifies system files
Archive : identifies files thathave not been backed up
The ATTRIB.EXE program is used to inspect andchange file attributes
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
25/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Attrib Attrib can be used to change the attributes
Use + to add attribute- Use to remove attribute
Attrib +R AILOG.TXT Makes it read only
Attrib H AILOG.TXT Makes it no longer hidden
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
26/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Working with FilesWildcards :
Wildcards are special characters that enablecommands to act on more than one file at a timeThe * represents any number of charactersThe ? represents a single character
DIR *.TXT Lists all files that end in .TXTDIR *.?XT Lists all files that end in XT
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
27/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Working with FilesREN command is used to rename files
DEL and ERASE commands are used to deletefiles
COPY command is used for making a copy of thefile in a new location
MOVE command is used for moving the file to anew location
XCOPY command is used for working withmultiple directories
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
28/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Mikes Five -Step COPY/MOVE Process
1. Point the command prompt to the directorycontaining the files to be copied or movedC:\> CD \DOCS
2. Type COPY or MOVE and a spaceC:\DOCS> COPY
3. Type the name(s) of the file(s) to be copied/movedand a space
C:\DOCS> COPY *.doc
4. Type the path of the new location for the filesC:\DOCS> COPY *.doc c:\Steam
5. Press ENTER
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
29/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Working with Batch Files
Batch files are text files that store a series ofcommands
One command on each lineBatch files use the .BAT extensionBatch files may be edited with any text editor
NotepadEDIT
Batch files get their own type of icon
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
30/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
EDIT
EDIT is a command-line command that starts abasic text editor
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
31/39
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
32/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Additional Commands
Some additional commands are
VER shows the current version of Windows
ECHO tells the batch file to put text on the screen
TYPE displays the contents of a batch file onthe screen
SET display settings that Windows has loadedby default
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
33/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
ECHO Command
ECHO will display text on the screen
ECHO OFF turns off the display of text on thescreen
@ at the beginning of a line prevents displayingthe command, but not the result of the command
@ECHO OFF is frequently used in batch files toclean up the appearance when the batch file isrun
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
34/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
SET and PATH Commands
SET will display the list of settings that Windowsloads by default
Programs (and batch files) are run from thelocation where the prompt is
If the program is not located in the current folder,you receive an error messageTo tell your command to look in other places, usethe PATH command
PATH by itself lists the current list of places to look fora programPATH= location; location; location; will add locations
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
35/39
Beyond A+
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
36/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
Using Special KeysF1 function key brings back the previouscommand one letter at a time
F3 function key brings back the entire commandat once
The DOSKEY command stores a list of all
previously typed commands and can beaccessed by using the up arrow keyType DOSKEY Windows XP/2000 automatically starts the program
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
37/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
COMPACT Command
COMPACTDisplays or alters the compression state of filescompact /c
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
38/39
2007 The McGraw-Hill Companies, Inc. All rights reserved
CIPHER CommandCIPHER
Displays or alters the encryption state of files/e specifies encryption operation/a says to apply it to the files as well as the directory
8/13/2019 MELJUN CORTES Computer Organization Lecture Chapter14
39/39