Mike Meyers’ A+ Guide to Managing and Troubleshooting PCs Instructor’s Manual Chapter 14

Chapter 14

Working with the Command-Line Interface

Learning Objectives

This lesson will assist you in learning to use the command line, to get familiar with common commands, and to be able to use command-line tools for troubleshooting and correcting errors. By the end of this lesson, you should be able to do the following:

·  Explain the operation of the command-line interface

·  Execute fundamental commands from the command line

·  Manipulate files and folders from the command line

Pre-test

1. What are file attributes?

2. How do you change directories from the command line?

3. How do you create a directory using the command line?

4. How do you remove a directory from the command line?

5. How do you copy files from the command line?

Lecture Outline

Discussion Point

Why learn the command-line interface?

The command line provides a powerful and quick way to work on a PC. While the CompTIA A+ Certification exams do not test specifically on DOS, the exams do include a wide variety of command-line commands. To be a good technician, you should be able to use the command line.

I. Historical/Conceptual

A. While programs tell the computer what to do and how to do it, the OS tells the computer how to communicate with the program and how to carry out the instructions of the program. The OS, among many other things, acts as the go-between for the system BIOS routines, the device drivers, and the hardware, and also acts as the go-between for the programs and the computer.

B. Operating systems have existed from the days of mainframes. When the microcomputer came along, Bill Gates found a primitive OS called Quick-and-Dirty Operating System (QDOS), bought it for a few thousand dollars, made some minor changes, and released it as MS-DOS. IBM made a few revisions to it and called it PC-DOS.

C. DOS is a command-line interface or a text-based OS. It is not as pretty as a GUI, and sometimes it isn’t as easy to configure, but in some respects it is far more robust and stable than any GUI. Although a new version of MS-DOS has not been released since 1994, the command-line interface has not gone away. Techs need it to troubleshoot and fix problems, and Microsoft has beefed up the commands in Windows XP.

IT Technician

II. Deciphering the Command-line Interface

A. Using the command-line interface is similar to having a conversation with computer.

1. The OS displays a prompt to indicate that it is ready to receive a command. The user types a command and presses enter. After the OS has completed the command, it displays the prompt again, “For the next step, if any?”

2. Whether you use a GUI or the command-line interface, the information available to you about files and folders is essentially the same.

B. Windows provides various ways of accessing the command line

1. Choose Start | Run. With Windows 2000/XP, type in CMD and press enter.

2. Choose Start | All Programs | Accessories to find the command prompt with Windows 2000/XP.

3. With Windows 95 or 98, you can boot directly to the prompt by holding down the f8 key when “Starting Windows 9x” displays on the screen. From the display menu, select Command Prompt Only.

4. To close the command-line interface window, click the Close button or type EXIT.

5. The command prompt focuses on a specific folder. The prompt indicates which folder is the default location. Any commands will be carried out on the files in that folder.

F. Filenames and file formats

1. Both the GUI and the command line use individual files, each of which has a filename. The filename has two parts: the filename (or primary filename) and the extension.

2. In DOS, the filename was limited to eight characters, with the extension up to three characters long. A period or dot separates the filename from the extension. You cannot use spaces or illegal characters.

3. Windows allows long filenames, up to 255 characters, and lets you use spaces in the filenames.

4. The extension identifies the type or function of the file.

5. Program files use the .EXE or the .COM extension. Different programs use a default extension to identify their files; for example, Word uses .DOC. Graphic files identify their graphics format or standard, such as .JPG for a JPEG format.

6. Changing the filename or extension does not change the content of the file.

7. Files are stored on the drive in binary format, but every program has its own way of reading and writing the binary data. Each unique method is called a file format. One program often cannot read the file format of another program.

8. The American Standard Code for Information Interchange (ASCII) defines a common or universal format that any program can read.

a) ASCII defines 256 eight-bit characters, including all letters, numbers, punctuation marks, and symbols that you can type on the keyboard as well as some special characters such as mathematical symbols or foreign characters that are not found on the keyboard.

b) The first 32 characters of the ASCII character set include control characters or special commands such as Tab or play a note (ring a bell) on the speaker.

c) ASCII cannot store characteristics such as shapes, colors, or font attributes such as font size, boldface, underline, italics, etc.

d) An ASCII file is also called a DOS text file or simply a text file.

e) Unicode data is a 16-bit code designed to be able represent characters in just about any language. The first 256 Unicode characters are the same as ASCII characters.

G. Drives and folders

1. The OS assigns a letter to each floppy drive and each hard drive partition. The letters A and B are reserved for floppy drives, with the first floppy drive assigned A:. The first hard drive partition is assigned as C: drive and other drives/partitions may be assigned through Z:. The CD-ROM drives get the next available drive letter after the last hard drive partitions. Windows NT/2000/XP let you change the default lettering for drives. Windows 2000 and XP let you mount a hard drive as a volume in another drive.

2. Windows uses a hierarchical directory tree to organize the contents of drives. The main level of the drive is the root directory. Files are organized into directories or folders that may, in turn, contain subfolders or subdirectories.

III. Mastering Fundamental Commands

A. Entering commands from a command line requires accuracy. You must enter them correctly, without error, or they will not work the way you want them to. A careless keystroke can result in loss of data with no warning.

B. The command line works from a prompt. Although it can be changed, the prompt is usually the current directory path, followed by a greater than sign () and a flashing underscore. For example: C:\>_ indicates the current location is the root directory of C: drive.

C. All commands use a similar structure or syntax. At the prompt, the first thing is the command itself followed by the target if different from the default or if necessary. Switches allow commands to be modified by adding a forward slash (/) and extra letters or numbers. Be aware that switches are specific to a command, and if the same switch is used with a different command, it may produce a different result.

D. Do not confuse the backslash with the forward slash. The backslash (\) means either the root directory or a division between a directory and a lower-level subdirectory or a filename. Use the forward slash (/) for switches.

E. You must press enter after typing a command to execute it.

Discussion Point

DOS command switches

A limited number of commands are available. The addition of a switch allows you to modify the command you are using. A switch is a modification added after the original command, separated by a forward slash (/). For instance, using the command DIR might give you a long list that scrolls way too fast to be able to read it. By adding the switch /P like this,
DIR /P,
you will see the same list with pauses between the pages so you can read the entire directory. You do not need to memorize every single switch to be good with DOS. After learning the secret tech handshake, you only need to know this secret quick help switch: /?. By entering any command with the switch /?, you will get a help file that describes what the command does and its syntax along with all available switches and their usage. Type
DIR /? and
you will see all the options for the DIR command. A space between the DIR command and the /? switch is not required, but it is a good habit because spaces are required in many other cases.

F. Commonly used commands

1. DIR (directory) command Shows a listing of the files and directories including the filename, the extension, file size in bytes, and creation date and time.

a) Different versions of operating systems display the results in different ways. In Windows 9x, DIR displays a short filename in the first column. This name represents the first six letters of the filename followed by a tilde (~) and a number. In the last column, Windows 9x displays the entire long filename. Windows 2000 and XP do not display the shortened filename.

b) By default, the DIR command displays a list of the files and subdirectories in your current directory location, but you can specify a different location.

c) By using various switches, you can customize the result. You should know at least three switches: /P pauses the directory listing when the screen is full, /W displays a wide directory listing that contains only the names of the files/subdirectories, and /S displays lower-level files and subdirectories. Use the /? switch to see which other switches allow special sorting, listing files of a certain type, listing hidden files, etc. For example, type DIR /AD to see only the directories in that directory.

2. The CD or CHDIR (Change Directory) command Changes or displays the name of the current directory. You can use this to know the current directory path or change path to the directory you want to be in. You can tunnel down one subdirectory at a time, or enter the entire pathway at once.

a) You can explore a drive by using the DIR command and then select the subdirectory you wish to go into. For example, if you see a subdirectory called WINNT, you would type CD WINNT. From there, you could type DIR again, select a subdirectory, and type the CD command again.

b) If you already know the path, you could type CD WINDOWS\SYSTEM32\DRIVERS to get to the drivers subdirectory, for instance.

c) By entering CD. . you could go up one level. The space is optional.

d) By entering CD \ you jump back to the root level of that drive. Again, the space in between the CD and the \ is optional.

3. Moving between drives You cannot switch drives using the CD command. To do that, just type the drive letter and a colon (For example, typing A: changes the location to the floppy drive and C: changes back to the hard drive.)

4. The MD (Make Directory) command Creates a directory. You can use this command to create a directory by putting a space between CD and the name of the new (child) directory.

a) The easiest way to make a directory is to change to the parent directory or the location where you want the new directory to be placed and then use MD newdir. For example, if you are at the root level of the drive, and you need to make a directory on the desktop of Windows, you would first go to that directory (CD WINNT\DESKTOP) and use the MD command: MD TEMP. This will place a new directory named TEMP on the Windows desktop, visible in Windows and from the command prompt.

b) If you want to make a directory that will be placed in a different location, you can specify the complete path or location starting from the root where the directory should be placed. For example, if you are located at C:\WINNT\DESKTOP and you want to make a new directory called NOTES that would be placed at the root, type the command MD\NOTES.

5. The RD (Remove Directory) command Removes or deletes a directory. If you are at the parent or the directory that contains the directory you want to remove, just type RD, a space, and the directory name. For example, if you are located at the C:\WINNT\DESKTOP directory, simply type RD TEMP to delete the directory named TEMP. However, RD will not delete a directory if it contains files or lower level subdirectories. Empty the directory by using the DEL command to remove files or the RD command to remove directories.

a) Windows 9x contains a command called DELTREE (delete tree) that will remove the directory and all of its contents, including any lower level subdirectories. You must type Y to confirm that you want to remove the directory. The DELTREE command is not included in Windows 2000. However, its ability to remove all the contents of a directory without emptying it first has now been built into the /S switch with the RD command.

G. Running a program

1. To run a program from the command line, change to the folder where the program is located, type the name of the program, and press enter.

2. Remember that files with the extensions .EXE and .COM indicate executable or program files. You do not have to type the extension to execute these files.

IV. Working with Files

A. Attributes

1. All files have four special values or attributes that determine how the file will act in special situations.

a) R (read-only) A write-protected file. Cannot normally be modified or deleted from the command line or Windows.