Sie sind auf Seite 1von 46

Adapted from "Windows Shell Tutorial Cay S.

Horstmann"
Operating Systems, User Interfaces, and Shells
The operating system manages the resources of a computer, such as its internal memory, the disk drives, keyboard, monitor screen, mouse, printers, and network connections. People who use a computer to browse the web or play games have minimal contact with the operating system. Most of their time is spent with application programs. Computer programmers have more advanced needs than people who use the computer as a tool. Programmers need to compile and launch programs and automate recurring tasks. This tutorial is written for programmers. Operating systems come with two different kinds of user interface:

a graphical user interface or GUI a command line interface, also called a shell

Most computer users are familiar with the graphical user interface or GUI. Most GUI environments display a desktop that is populated with windows, icons and menus. You use a pointer (directed by a mouse or trackball) to select items on the desktop. These interfaces are sometimes called WIMP interfaces, after the first letters of the words window, icon, menu, and pointer. Here is a screen capture of a typical WIMP interface:. The other user interface is a command shell. A command shell is simply a window without any graphical decorations. You type commands, using the keyboard, and you see the results of the commands displayed as text. There are no icons, and you can use the mouse only in limited circumstances. Here is a typical command shell: A command shell is not a good user interface for casual users. However, experienced users find that the command shell is indispensible for many tasks.

Keyboard Shortcuts
PART 1 Running a program

You probably know how to launch programs by clicking on the start button or on desktop icons. We will now introduce another method. Type the keyboard shortcut Ctrl+Esc. That is, hold down the Ctrl key, and, without lifting your finger off it, hold down the Esc key. Then let go of both keys (in either order). This keyboard shortcut simulates a click on the Start button. Why use a keyboard shortcut? It is much faster to hit Ctrl+Esc than it is to 1. grab the mouse 2. move the mouse to the lower left corner of the screen 3. click the mouse button You will see a popup menu, containing icons and names. The exact layout of the menu depends on the version of Windows and on the customization of the start menu. Here is one example. Your dialog may well be quite different.

NOTE: If you use Windows XP, it is a good idea to switch the start menu to "Classic" mode. The setting is inside the Taskbar and Start Menu control panel. (While you are at it, you should switch the control panel view to "Classic" mode as well.) NOTE: If you use Windows XP, the underlined letters may not show up until you hit the Alt button. This unfortunate behavior can be corrected in the Display Properties control panel dialog. Select the Appearance tab and click on the Effects button... NOTE: In most dialog boxes, hitting the Enter key is the same as clicking the Ok button. Typing Esc dismisses the dialog, just as if you had clicked the Cancel button.

In any menu, you can quickly select items that have underlined letters in their names. For example, typing R is the same as selecting the Run item. Typing H is the same as selecting the Help item. Hit theR key now. You will get a dialog. Type the word notepad. Hit the Enter key now. The Notepad program launches.
Exercise 1 Which keystrokes are required to launch the Notepad program without touching the mouse?

ANS

Exercise 2

What is the advantage of using the Run dialog to launch the Notepad program? Hint: Locate the Notepad program in the start menu tree. In which subm take you to find it? Will it be in the same position on your friend's computer? ANS

PART 2 Toggling between programs Run your web browser and notpad. You now have two windows on your desktop: the browser and the Notepad program. This is an extremely common situation for a programmer. You will often write a program in one window while consulting documentation in another window. It is essential that you can switch quickly between the windows, even if some windows hide others. The fastest way of switching between windows is the Alt+Tab keyboard shortcut. Press Alt+Tab now. You will get a dialog that lists all windows. Release both keys. You instantly switch to the next window.

Start the calc program (Ctrl+Esc R calc Enter). You should now have three programs running. Hit Alt+Tab again, but this time keep the Alt key depressed and repeatedly hit the Tab key. You toggle through the program icons. Let go of both keys when you have reached the browser program.
Exercise 3 Run three programs, for example, a browser, the notepad, and the calc program. Switch to the browser program if it is not currently active (either with Hit Alt+Tab and let go immediately. Which program is selected now? ANS Hit Alt+Tab again and let go immediately. Which program is selected now? ANS Why is the result surprising? Why is it useful? ANS

PART 3 Managing windows When the time has come to close an unwanted window, you can close it by clicking on the X icon in the top right corner, or you can use a keyboard shortcut. There are actually two shortcuts. The combination Alt+F4 closes the active window, but even keyboard enthusiasts will find it hard to remember. More useful is the Alt+Space shortcut. It brings up the window menu:

Select C to close the window. The window menu has a number of other useful options:

Maximize: Make the window fill the entire desktop Restore: Restore the window to its original size, before maximizing Minimize: Temporarily remove the window from the screen (to reduce clutter)

You can get a minimized window back onto the desktop by cycling to it with Alt+Tab.
Exercise 4 Suppose you want to see as much information as possible in your browser window. What keystrokes do you use to maximize the browser window? ANS Please note: you can also get a different style of full screen on most browsers by pressing F11 (ie function key 11). Try it.

PART 4

Cut, Copy and Paste

One of the most common operations for text manipulation is cut-and-paste: transferring information from one place to another. Because these operations are so common, there are special keyboard shortcuts for them. Switch to the notepad window. Pull down the Edit menu by typing Alt+E. Note the underlined E in the menu name. You pull down a menu by typing the Alt key and the underlined letter.

The Edit menu has commands for the Cut, Copy, and Paste operations. Thus, a perfectly reasonable keyboard shortcut for copyin because the copy operation is so common, there is an accelerator, Ctrl+C, that lets you access the operation with a single key co listed in the menu. Similarly, there are accelerators for cut (Ctrl-X) and paste (Ctrl-V). These key combinations are perhaps not helpful to visualize the X as crossing out text, and the V as an insert mark for adding text:

Also note that the letters X, C, V are located next to each other, conveniently close to the Ctrl key (at least, on the standard English QWERTY keyboard layout).
Exercise 5 Now switch to the browser window. If it doesn't currently show a document, then visit your favorite web site. Use the mouse to select a phrase of your selected text to the Notepad program, without further use of the mouse. What keystrokes to you use? ANS

Part 5 Moving the Cursor and Selecting Text You can move the cursor by clicking on the desired location, and you should do that if the desired location is far from the current location. However, if you just need to move the cursor by a small amount, it is often faster to use the following keys:

The arrow keys Left, Right, Up, Down move the Ctrl+Left, Ctrl+Right move the cursor one word Home, End (above the arrow keys) move the cur

PageUp, PageDown (above the arrow keys) scro faster than using the scroll bars.

You know that you can select text with the mouse, by clicking on the beginning of the text and dragging the mouse to the end. Indeed, that is often the fastest method. However, if you need to select a short amount of text and your fingers are on the keyboard, then it is useful to know a shortcut. Hold down the Shift key and move the arrow keys. You will see that a portion of text is selected. You can also use keys such as Home and End to extend the selection to the beginning and the end of a line.
Exercise 6

Switch to the notepad. It should still contain some text from a preceding exercise. If not, paste or type a couple of lines. Now highlight the entire line c

keystrokes as possible. What keystrokes to you use? ANS

PART 6 Navigating in Dialogs It is handy to know how to move quickly through the fields of a dialog box without using the mouse. In any dialog box, you can use the Tab key to cycle through all of the fields and buttons. Consider for example the following dialog from the Notepad program. (The menu option is Edit -> Replace.)

NOTE: This is the dialog from Windows XP. If you use an older version of Windows, use the Search -> Find dialog instead. It isn't as interesting, but you can still use it to try out the Tab key behavior.

Type the Find what entry, then hit the Tab key to quickly get to the Replace with field. The Tab key is particularly handy for dialogs that have many text fields.

When you use the Tab key to cycle through the dialog box, observe how the focus shifts from one field to the next. A text field with focus has a blinking cursor. A button with focus has a dotted rectangle around the button label. The focus tells you which part of the dialog box receives keyboard input. For example, if a button or checkbox has focus, then hitting the Space bar is the same as clicking it with the mouse. If an item name has an underlined letter (such as Match case), then you can type Alt together with the underlined letter to reach it quickly. For example, Alt+C is the same as clicking theMatch case checkbox. Finally, most dialogs respond to two special keys. Typing Esc dismisses the dialog, just as if you had clicked the Cancel button. Typing Enter is the same as clicking the Ok button.
Exercise 7

Open up the Find dialog in Notepad. What keystrokes do you need to find the next occurrence of Hello, with Match case checked? Keystrokes only ANS

PART 7 The File System


Disk drives Disk drives for computers come in two main types, removable (floppy, CD ROM) and non removable (hard). Whether hard or floppy, a computer disk drive essentially contains a round, flat, object, and it reads its surface with a magnetic or optical head. In addition to the disk drives that are physically present in a computer, there may be several mapped drives that are provided by the network server. These are not actual drives at all, but look to the operating system (and to you) as

though they are. The drives that hold the disks are named by a letter followed by a colon ( :). The names a: (and perhaps b:) are the floppy drives. The names c: and d: are usually used to name hard disk drives in that same computer. CD ROMS come next, labeled e: (or d: if there is only one hard disk). Higher letters like j:, k:, ... are mapped network drives.
NOTE: Sometimes, a single hard drive has multiple partitions. Even though there is only a single physical drive, it divided into several areas, each of which has its own drive letter (c:, d:, ...). If you set up your own computer, it is an excellent idea to set up two partitions, one for the operating system (c:) and one for your personal data (d:). That setup enables you to reinstall the operating system without interfering with your personal data. (Unfortunately, the Windows operating system is notorious for becoming unreliable over time, as more software is installed and programs and drivers interfere with each other. The best remedy is to periodically wipe the c: partition clean and reinstall Windows.)

NOTE: In Linux/Unix/Mac OS X, there are no drive letters. Instead, CD ROM and floppy drives are accessed through paths such as /mnt/cdrom and /mnt/floppy.

There are many ways to using Windows. The pro Explorer. (This is not th Microsoft's web browser explores the file system, program, open the Run d type explorer followe

Exercise 8 List some of the available drives with their names and drive letters. (You may need to open the My Computer item.) Also indicate if its a Hard-drive partition CD-ROM Network drive ANS

Each drive contains files and directories (also called folders). In the Explorer program, click on a drive to see the files and folders. The files are depicted with an icon that looks like a file folder. Files have different icons that depend on their type.

Exercise 9 How many files and directories are on your c: drive. (just the C: directiory ... not its directories.)

ANS

Directory Trees A typical hard disk holds thousands of files. It is therefore essential to organize your files on the disk. As you accumulate files on a disk, you store them in groups by creating directories. Each directory can contain any number of files and other directories called subdirectories. This arrangement is known as a hierarchical or treelike directory structure. To visualize the hierarchy of directories, it is best to look at the tree view to the left of the Explorer window (to enable this in Explorer select VIEW | EXPLORER BAR | FOLDERS). Note that each drive has a small box next to it with either a + or - sign in it. This indicates whether the next level of the directory hierarchy is hidden or expanded. Click on the + icon to expand a hidden level, on the - icon to hide an expanded level. On each drive, the hierachy starts with the root directory. The name of the root directory is simply the drive name followed by a backslash (such as c:\). The root directory contains files (such as c:\logfile.txt) and directories (such as c:\windows). The windows directory contains other files (such as c:\windows\notepad.exe) and directories (such as c:\windows\system). The sequence of subdirectories from the root to a given file or directory is called the path. For example, c:\windows\system is the full path name of the system directory inside the windows directory inside the c: drive.

Exercise 10 List a file and a directory in the c:\windows\system32 directory. Give the full path names for the file and directory ANS

Exercise 11

Starting in c:\windows\system32 find the files find.exe and telnet.exe. Give the full path names. (Hint: You may find it easier to look for files if you se view for directories. Choose the View -> List menu option.) ANS

Exercise 12 Find a file whose full path names contains at least four directories. ANS

NOTE: In Linux/Unix/Mac OS X, directories are separated by forward slashes (/). For example, /usr/local/java/bin. That is the same convention as for web page addresses. Only Windows uses backslashes (\).

Making Directories
Exercise 13

Create a subdirectory called tutorial inside the c:\yourname directory. (Substitute the actual directory that you created.) List all steps, starting w Don't use the mouse! (Close it first if it is currently running). ANS

File and Directory Names You can use letters, numbers, the underscore (_) and the hyphen (-) character in file names. Obviously, you can't use symbols such as : and \ in file names, or they would be confused with drive and directory separators. There are a few other special characters that you can use, but the details depend on whether the drive is a local drive or a networked drive. It is best to avoid file names with exotic symbols such as !@#$. You can use spaces in file names, but programmers rarely do that, because spaces in file names create problems when you use a command shell. Instead, use - or _ to separate words: myprojectver0.01.java or letter_to_fifi.txt.

Both uppercase and lowercase letters are permitted in file and directory names, but Windows will not distinguish between names that differ only in the case of the letters.
Exercise 14 Create file called "my name.txt " and "my_name.txt" and "my-name.txt". Which style do you prefer? ANS

Files Start the Notepad program: Ctrl+Esc R notepad Enter. Type a few words. Select File -> Save As from the menu. You will get the Windows file dialog.

The dialog suggests a file name *.txt. However, you can't actually use the *character in a filename. Also, the current directory is likely to be wrong. Fortunately, in most versions of Windows, the useless default is also highlighted, so you can overtype it. Note the "Save as type" dialog - select " Text documents". When you save your file with name mytext for example windows appends ".txt " onto the end of the file. Also note as you type c:\yourname\. (Actually, type the name of your personal directory.) Type the letters s l o w l y and pay close attention to the entry

field. You will see that a small menu below the entry field is filled with the names that match what you have typed at this point.

This feature is a great time-saver. As soon as you see the name that matches what you want to type, hit the Down arrow button to select it. Presenting all choices that match the typed letters is called incremental search. Clearly, incremental search is a marvelous convenience because it minimizes the number of keystrokes.
Exercise 15 What choices do you get after you type the letter c (or whatever the drive letter of your personal directory is)? What choices do you get after you type name? ANS

Save the file as c:\yourname\tutorial\sample.txt.


Exercise 16

Close the Notepad program and locate the file that you just saved in the Explorer program. What icon does it have? What name is displayed for the file on the file name?

ANS

Depending on the configuration of Windows, the extension .txt may not be displayed when you view the file in the Explorer program. By default, Windows hides the extensions, presumably because naive users are confused about file names such as letter to aunt tilly.txt.

PLEASE NOTE
Hiding extensions is primarily helpful for virus writers. Many Windows users have eagerly double-clicked on icons labeled something like prettygirl.gif, only to launch a virus program whose real name was prettygirl.gif.exe.

As a programmer, you don't want the operating system to hide information from you. Fire up the Explorer program and select Tools -> Folder Options and select the View tab.

ake sure the check box next to "Hide file extensions for known file types" is unchecked. Click on it if it is checked. Then hit Enter or click OK. Make sure to repeat this step on every Windows computer that you use.

Windows uses the file extension to figure out what to do with the file when you double-click on it. Double-clicking on a .txt file brings up Notepad. Double-clicking on a program file (with extension .exe) executes the program. You can find out which program corresponds to a particular extension. In the Explorer program, select Tools -> Folder OptionsFile Types tab. You get a list of all file types that are registered with Windows. You (or a program that you install) can modify these associations.
Exercise 17 Which program is associated with the extension .html? Which program is associated with the extension .gif? ANS

Context Menus Items such as file and directory icons in the Explorer display have context menus that contains commands directly related to the item. This menu can be displayed by clicking on the object's icon with the right mouse button.

One of the most useful entries in the context menu of a file is Rename. To rename a file, right-click on the file, select Rename and type the new file name.
Exercise 18

Write down dome of the commands listed in the context menu for the c: drive? What are the commands listed in the context menu for the c:\yourna Is there differences to the hard drive content ment? ANS

Moving and Copying Files Files and directories often need to be copied. There are two methods for copying files with the Explorer program. The most intuitive method is drag-and-drop: select a file with the mouse, drag it to another directory, and drop it. If you hold down the Ctrl key while dragging the file, it is copied, not moved. With some manual dexterity, you can also drag a group of files. To select more than one file, depress the Ctrl button and click on all files in the group. For selecting multiple files with similar properties (such as the same extension, or similar modification dates), you may find it helpful to switch to a tabular view (menu option View -> Detail). Depress the Shift button and use the Up and Down arrow keys to select a contiguous set of files. The difficulty with drag-and-drop is that both the source and target directory need to be on the desktop. You can overcome that problem by cutting and pasting files. Select the files you want to move or copy. Then select Edit ->

Cut (or simply Ctrl+X), move to the directory into which you want to move the files, and select Edit -> Paste (Ctrl+V). To copy the files, use Edit -> Copy instead.
Exercise 19 Copy all files with extension .txt into the c:\yourname\tutorial directory. What sequence of keystrokes and mouse operations did you use? move them!) ANS

Backing up your work The best method for backing up your work in a computer lab is an online service such as http://www.xdrive.com/ which promices 5GB of free online space. You can save files on an external server and load them back either onto the same computer (in case you need to restore a lost or corrupted file), or onto another computer (in case you need to move your work between your lab and home computers).
Exercise 20

Back up the file c:\yourname\tutorial\sample.txt, either onto an online service or onto a floppy. Describe the steps that you took. Now d backup. What steps did you take to restore the file? ANS

PART 8 ********* The Command Shell ********


You have now learned how to navigate the Windows desktop effectively. The final part of this tutorial covers the command shell. You may wonder why you need to learn another method for achieving the same tasks. There are three reaons: 1. It is much faster to type certain commands than clicking and dragging with the mouse. For example, suppose you want to erase all text files in a folder. In a GUI, you select all text files and then drag them to a trash can icon. In a command shell, you type a few keystrokes such as
del *.txt

2. You can save the output of a command for later processing. For example, suppose you want to do something with all text files in a folder. You can save their names in another file with a command such as
dir *.txt > names.dat

Try doing that in a GUI. If you take a screen capture of a folder display, all you get is a bunch of pixels.

3. You can automate repetitive commands. For example, suppose you have multiple text files and want to compress each of them into a separate file. You can use a loop such as
for %f in (*.txt) do jar cvf %f.zip %f

Reads Find all file names with .txt extension (e.g. myfile.txt) and assign each name to the variable f (myfile) int turn and then jar up (like zip like program)into a zip file with the same name as the name of the txt file.. 4. When there are many files to process, such an operation would be very tedious with a GUI. Many worthwhile tasks are never attempted by GUI users just because they don't know how to automate them.

Starting the Command Shell

Open the Run menu and type

cmd

(or command if you use a version of Windows prior to XP):

Ctrl+Esc R cmd Enter. The command shell window appears:

The command shell has a rather primitive user interface.


A prompt shows the current directory, such as c:\windows. You type a command and hit the Enter key. The command is executed. Its output is displayed in the shell window. Another prompt is then displayed, and the process repeats until you close the shell window.

Exercise 21

What prompt is displayed when you open up a command shell window? ANS

Type the command dir followed by the Enter key into the shell window. You will see a listing of the files and directories in the current directory.
Exercise 22 How many files are contained in the current directory? How many directories? ANS

Now type the command cd \ This should take you to the root directory. thes C: in Windows. Don't forget hitting Enter.

Exercise 23 What does the prompt string look like now? ANS

Exercise 24 When you are in the root directory type cd \ again. What happens? ANS

Now type cd \yourname As always, replace yourname with your personal directory name. If your directory is contained in a drive other than C:, you first need to switch to the other drive by typing the drive letter followed by Enter, for example
j: cd \users\jqsmith

Next, type cd tutorial

Exercise 25 What does the prompt string look like now? ANS

Type cd ..
Exercise 26 What does the prompt string look like now? Whats happening? ANS

Finally, type cd \tutorial


Exercise 27 What happens? Explain. ANS

You have just learned the basic directory commands in the shell: Typing cd plus a path changes the directory to the given path. Here a path can be relative to the current directory or absolute. Absolute paths always start with the root directory ( \). Relative paths begin with a file name in the current directory. There is one special file name that is very useful: the double period ( ..) refers to the parent directory of the current directory in the directory tree, so that it is possible to go up the tree with relative paths as well as down. Similarly, the filename . refers to the current directory, but that abbreviation is not commonly needed. Typing dir lists files in the current directory. You can also give dir a relative or absolute path, and it will display the appropriate directory, such as
dir ..\projects

Command Line Editing Some people dislike using the command shell because it is tedious to reissue commands that were mistyped. Fortunately, it is possible to retrieve and modify previously issued commands. Hitting the Up and Down arrow keys cycles through the commands that you already typed.
Exercise 28 What command do you see when you hit the Up arrow key? What command do you see when you hit the Up arrow key again?

ANS

NOTE: If the arrow keys don't retrieve old commands and you run Windows XP, double-check that you are running cmd and not the older command shell. If you have an older version of Windows, you need to run the doskey program to enable command line editing. Simply run doskey after you open a command shell.

Exercise 29 Type c and the F8 key. Hit F8 repeatedly. What happens? ANS

The F8 key performs a search of the previous commands that start with the text you have already typed. This is often the fastest method for retrieving an old command. You can use the cursor keys (Left, Right, Home, End) to edit the line that you called back. Move the cursor where you want it and insert or remove characters. If inserting characters types over existing text, hit the Ins key to switch from overtype mode to insert mode.
Exercise 30

Type cd \windos (note the misspelling). After you get an error message, use command-line editing to fix it to cd \windows. What are the key st

ANS

Another very useful feature of the shell is filename completion. If you type a part of a filename and hit the Tab key, then the first matching file is displayed. Hitting Tab again cycles through all matching completions.
Exercise 31 Type cd c:\w and hit Tab. What happens? ANS

NOTE: Filename completion only works with Windows XP. It does not work with older versions of Windows.

Finally, if you look for a command and you don't find what you want, you can clear the command line and start over by hitting Ctrl+C. Indeed, this command can be used to stop almost any action that is still in progress. File Commands The del command deletes a file. For example,
del sample.txt

deletes the file sample.txt.

NOTE:When you delete a file with the del command, it does not get moved into the trash can. It is deleted for good and cannot be retrieved.

To copy a file, use the copy command, followed by the target file or directory. For example,
copy sample.txt sample.bak

copies the file sample.txt and names the copy sample.bak.


Exercise 32 How would you achieve the same effect using the Explorer program? ANS

copy sample.txt a:\

copies the file sample.txt into the directory a:\. Because the target of the copy command is a directory, the copied file keeps the same name. To move a file, use the move command. For example,
move sample.txt a:\

moves the file sample.txt to the directory a:\, removing the original.

You can also use the move command to rename a file. The command
move sample.txt sample.bak

renames the file sample.txt to sample.bak.


Exercise 33 How would you achieve the same effect using the copy and del commands? ANS

Directory Commands The mkdir command makes a directory. For example,


mkdir \yourname\homework1 cd \yourname\homework1 mkdir backup

Exercise 34 Execute these commands. What is the full path name of the backup directory that was created? ANS

You remove a directory with the rmdir command. However, in order to be removable, a directory must be completely empty. That is, you must first remove all files and directories that it contains.
Exercise 35 Execute thes command
rmdir \yourname\homework1

What error message do you get? How can you remove the directory? ANS

Wildcards Often when we want to copy files, we only want files of a certain type (that is, with a certain file extension). For example, we may want to copy only text files (with extension .txt). We use the wildcardnotation for this purpose. The command
copy *.txt a:\

copies all files whose names end with .txt to the a:\ directory.
Exercise 36

How would you copy all text files from the c:\windows directory to c:\yourname? Why is this a better solution than the one you found in exerci ANS

Exercise 37 What does the folowing command do?


del c:\yourname\*.*

ANS

The asterisk (*) in the entry *.txt stands for any sequence of characters of any length. (Note how the file extension is given separately.) The other wildcard that is available is ?, which stands for any single character. Here are two more examples of the use of these wildcards:

The string s*.txt matches all files beginning with the letter s and having the extension txt. The string st??.ba? matches all files beginning with the letters st whose filenames have four characters, and whose extensions consist of three characters beginning with ba.

Exercise 38

Use the dir command and wildcards to find all files in c:\windows that start with a w, have three letters, and whose extension is ini. What comm you get? ANS

Command-Line Options

Many shell commands take options that modify their behavior. For example, the dir command has an option /w that produces a "wide" listing, with several files in each line. The command is
dir /w

for a wide listing of the current directory, or


dir /w c:\windows

for a wide listing of the Windows directory. Another useful option of the dir command is /p.
Exercise 39 Try the command dir c:\windows /p. What is the effect of the /p option? ANS

You can combine multiple options:


dir /w /p c:\windows

In general, an option to a command starts with a forward slash, followed by a letter. Note that forward slashes (/) are entirely different from from backslashes (\), which are path separators. Most commands have several options, which

you can find in the online help. You can also get a brief description of a command and its options through the /? option, for example
del /?

Exercise 40 What are all options of the del command? ANS

NOTE: In Linux/Unix/Mac OS X, you use a dash, not a forward slash, for options. For example, ls -a.

Copying from and to the Shell Window Sometimes, you need to copy information from a command shell window into another window (for example, to include output in a report or email). Unfortunately, this process is somewhat cumbersone.

Right-click on the command shell window. A context menu pops up. Select the Mark option. Use the mouse to select a rectangular area. (You can also use the cursor keys. Hit Down to move to the first line that you want to copy, then press Shift+Down to select the lines you want to copy.) Hit Enter Switch to another program (such as Notepad) and paste ( Ctrl+V).

Obviously, this method can only be used to copy a single screen to Notepad or another application. To get more than one screen, you will need to use redirection, which is described in the advanced lab.

Conversely, you may want to copy a command from another program (such as a web browser) into the shell window. Copy the command, then right-click on the shell window and select the Paste option.
Exercise 41 Copy this command into the shell window and execute it. What happens?
dir /oen /p c:\windows

ANS

Executing Programs To execute a program from the command shell, you type the program name. For example, to launch the Explorer program, type
explorer

You can also provide command-line arguments. For example, to launch the notepad program and edit a particular file, simply specify the file name.
notepad c:\yourname\tutorial\sample.txt

Exercise 42 Execute the command What happens? Explain.


notepad c:\yourname\tutorial\myfile.txt

ANS

When you give the name of a command, then Windows tries to find an program file with that name. For example, when you type notepad, then Windows looks for the file notepad.exe. It looks for the program file in the current directory, then in a set of standard places that include the c:\windows and c:\windows\system32 directories. If the program file is not found, then an error message is displayed.
Exercise 43 Execute the command (Note the misspelling). What happens? Explain.
notpad

ANS

Sometimes, you need to execute a file that is not a part of the "standard places". For example, if you install the Java compiler, it is installed into a directory such as c:\j2sdk\bin. By default, Windows will not look inside that directory. You can, however, launch the program by giving the full path name
c:\j2sdk\bin\javac MyProg.java

You will see a better solution in the advanced lab. Exiting the shell To close the shell window, type the command
exit

Alternatively, simply close the shell window.


Exercise 44 Execute the command. What happens?
exit

ANS

Das könnte Ihnen auch gefallen