Embed
Email

Chapter 7 The Command Line

Document Sample

Shared by: xiang
Categories
Tags
Stats
views:
23
posted:
11/14/2011
language:
English
pages:
16
Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-1







Chapter 7

The Command Line



At a Glance



Instructor’s Manual Table of Contents

• Overview



• Objectives



• Teaching Tips



• Quick Quizzes



• Class Discussion Topics



• Additional Projects



• Additional Resources



• Key Terms

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-2







Lecture Notes



Overview

Before the advent of the graphical user interface (GUI), the only way to interact with

the operating system was through the command-line interface (CLI). Given the user-

friendly features of the GUI, use of the CLI has declined. However, the CLI should still

be learned for a number of very good reasons: task efficiency, resource efficiency,

emergency backup, refined commands, and programming skills.





Objectives

• Use the command line

• Access Help files

• Display the contents of files

• Create script files to automate simple tasks





Teaching Tips

Using the Command Line

1. Use Figure 7-1 to illustrate the process of a command by the command console.



2. Identify three data streams: STDIN (standard input), STDERR (standard error), and

STDOUT (standard output).



3. Indicate that both input and output can be redirected; for example, by sending output to

a file instead of the standard output device (the monitor).



Using the Command Line with the Windows XP CLI



1. The following sections cover configuring the command environment and using the

command prompt.



Customizing the CLI Window



1. The CLI customization menu can be accessed by right-clicking the title bar of the

command prompt (see Figure 7-2).



2. Define the term taskbar.

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-3



3. Review the various CLI menu options, such as Restore, Defaults, and Properties. Focus

on two dialog boxes: Console Windows Properties and "Command Prompt" Properties

(see Figure 7-3). Explore the Options tab of the first dialog box and the Font, Layout,

and Colors tabs of the second.





Teaching Inform students that Console Windows Properties and "Command Prompt"

Tip Properties have the same appearance, but serve different functions. The former is

used to set defaults for future command prompts; the latter is used to configure

the current command prompt.





Using the Command Prompt Edit Menu



1. To display the Edit menu of the command prompt (see Figure 7-4), right-click its title

bar and then click Edit.



2. Describe the Edit menu options: Mark, Copy, Paste, Select All, Scroll, and Find.



3. Reinforce the point that the mouse can be enabled for use with the command prompt by

checking QuickEditMode.



4. Explain how to copy and paste using either the mouse or the Mark option.



Using the Command History



1. You may view past commands by using the up/down arrow keys at the command

prompt.



2. You may also call the list of commands by pressing F7 (Figure 7-5). Move up and down

the list using, respectively, the up and down arrow keys. Pressing Enter causes the

highlighted item to execute. Press Esc to close the window.



Using Shortcut Keys



1. Remove the time-saving function keys listed in Table 7-1.



2. Provide examples demonstrating the convenience of shortcuts. For instance, F2 is useful

for copying part or all of the most recently entered command. Figure 7-6 shows the

results of using F2 to copy CD "\Program Files\TextPad 4" up to the character "T".



Completing Filenames and Directory Names



1. Enter CMD /F:ON to enable filename and directory name completion.



2. To use the completion feature, type a partial directory name or filename at the

command prompt and either Ctrl+D or Ctrl+F. Figure 7-7 shows the results of entering

CD \pro and then Ctrl+D.

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-4



3. If multiple directory names or filenames match the characters you enter, press the key

combination again to move to the next instance. Press Enter to execute the command.



Console Redirection



1. You may redirect output to a file or printer. Describe the appropriate syntax, including

the ">" operator. Indicate that printers are specified with the UNC (Universal Naming

Convention ) format.



2. Provide examples of redirecting output to a file and a printer.



3. Explain that input may also be redirected using the ", >>) with the pipe (|) operator. How do

both broaden your command processing capabilities?



4. What are the benefits of becoming acquainted with the Help files in Windows XP and

the man pages in Fedora Core 4?



5. Why is a script considered to be a kind of program?



6. What are the benefits of batch programming?



7. How does the use of repetition and decision-making structures enhance your scripts?

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-14





Additional Projects

1. Practice using the command prompt shortcut keys shown in Table 7-1. First, enter the

following command at the CLI prompt: CD "\Program Files\TextPad 4". Next, use

shortcuts to perform the following tasks:



• Bring back the entire command just entered.

• Move the cursor to the beginning of the line.

• Delete the characters making up CD.

• Show the command history.

• Re-enter the original command from the historical list.



Identify the primary function key used for each task. Were the shortcuts used the most

efficient way to perform the given tasks? Explain in 1- 2 paragraphs.



2. Compare the search operations in the Vim editor (discussed in Chapter 6) to search

operations performed with the grep command. Is there any relationship between the

two? Are there significant functional differences? Which approach is more user-

friendly? Summarize your findings in 2-3 paragraphs.



3. Scripts are actually program segments. As such, they can be described in terms of

syntax and semantics. Research the meaning of the words "syntax" and "semantics" in

relation to programming. Refer to the code segment at the end of the section entitled,

"The Six-Step Problem-Solving Process". Describe the syntax and semantics of the

code segment. Summarize your results in 2-3 paragraphs.



4. Use the six-step problem-solving process to construct a shell script that performs the

following:



• Adds the odd numbers from 1 – 100.

• Echoes each calculation performed.



Hint: You will need to define variables and create repetition and decision structures.

Record each of the six steps. Before coding the routine, write the algorithm in English

pseudocode. Ensure that your implementation is commented.

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-15





Additional Resources

1. General information about the CLI:

http://en.wikipedia.org/wiki/Command_line_interface



2. Windows XP CLI:

www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-

us/ntcmds.mspx?mfr=true



3. KDE Konsole:

http://konsole.kde.org/

4. Using filters in Windows XP:

www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-

us/filters.mspx?mfr=true



5. Batch programming:

www.computerhope.com/batch.htm#1



6. Linux Shell Scripting:

www.freeos.com/guides/lsst/





Key Terms

batch program: A program that executes without interacting with the user.

chmod command: A command in Fedora Core 4 that changes file permissions.

CompareOp: A three-letter comparison operator used by the IF command in Windows

XP.

cut command: A command in Fedora Core 4 that extracts fields from a line in a file or

extracts an entire record from a file.

ECHO command: A command that displays text to the standard output device.

environment variables: Named storage locations you can use to determine the

behavior of the command processor and the operating system. Two types are available:

system and local environment variables. You need administrative privileges to use

system variables; you can use local environment variables to control the operation of

batch files.

FOR command: A command that executes a section of code a specified number of

times in Windows XP. Command syntax can vary depending on the task the loop needs

to perform.

for in command: The Fedora Core 4 version of the for command. You can use the

command without the in and vary the syntax depending on the task the loop needs to

perform.

GOTO command: A command you use in Windows XP programs to transfer execution

to some other statement; the high-level equivalent of a branch or jump instruction.

grep (global regular expression print) command: A command in Fedora Core 4 that

searches a file or files by keyword.

head command: A command in Fedora Core 4 that prints the first 10 lines (by default)

from a file to standard output.

Guide to Parallel Operating Systems with Microsoft Windows XP and Linux 7-16



IF command: A Windows XP command that executes a block of statements if a

decision expression evaluates as true; when an ELSE clause is included, its statements

execute if the decision evaluates as false.

if else fi construct: A command in Fedora Core 4 that works like the IF command in

Windows XP when the ELSE clause is included.

if fi construct: A command in Fedora Core 4 that works like the IF command in

Windows XP.

less command: A command that allows backward movement when you view file

contents.

man pages: The Help file documents in Fedora Core 4.

parameters: In programming, a value given to a variable, either at the beginning of an

operation or before a program evaluates an expression. The parameter can be a string, a

number, or another parameter name.

PAUSE command: A Windows XP command that temporarily stops the operation of a

program or command.

REM command: A Windows XP command to add comments (remarks) to a program

or batch file.

script: A program that consists of a set of instructions to control some function of an

application or utility program; these instructions typically use the rules and syntax of

the application or utility.

SET command: A Windows XP command that displays, creates, or removes

environment variables.

SHIFT command: A Windows XP command that changes the position of batch

parameters in a batch file.

synopsis: A term used in the Fedora Core 4 man pages to describe the syntax of

commands.

tail command: A command in Fedora Core 4 that typically prints the last 10 lines or

bytes of a file. For large files, this command can provide faster access to data within the

file.

taskbar: A graphic toolbar used in Windows operating systems to select active

applications.

TYPE command: A Windows XP command that displays the contents of a text file on

the standard output device.

UNC (Universal Naming Convention) format: A system of naming files on a network

so that they have the same pathname when accessed from any of the networked

computers.

while command: A command that enables you to execute a group of statements a

specified number of times.



Related docs
Other docs by xiang
[.PPT] Esfahan.ppt - PowerPoint Presentation
Views: 257  |  Downloads: 1
SO_RAL_Low_Sodium
Views: 0  |  Downloads: 0
Early Signs and Symptoms
Views: 1  |  Downloads: 0
Lecture 5 - PowerPoint Presentat
Views: 5  |  Downloads: 0
Individual Response for Unit Analysis
Views: 0  |  Downloads: 0
Slajd 1
Views: 1  |  Downloads: 0
xsdasadas
Views: 0  |  Downloads: 0
Intervjuer deltagare i EU-projek
Views: 1  |  Downloads: 0
Terms of Reference
Views: 0  |  Downloads: 0
Special End of Season Issue
Views: 15  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!