Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 7 pdf

68 207 0
Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 7 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

12 12-14 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D History in the Korn Shell Re-Executing Commands The r is a custom command (alias) in the Korn shell. This enables the user to re-execute commands from the history list. Command Format r[ argument(s) ] The argument passed to the r command is the history line number of a particular command, or a letter indicating the most recent command in the history list that started with that letter. 12 Basic Features of the Korn Shell 12-15 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D History in the Korn Shell Re-Executing Commands $ pwd /home/user2 $ r pwd /home/user2 $ history 27 27 cd /usr/dict 28 history 23 29 history 22 24 30 pwd 31 pwd 32 cd ~ $ r 27 cd /usr/dict $ pwd /usr/dict $ pwd /usr/dict $ r p pwd /usr/dict 12 12-16 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D History in the Korn Shell Editing the Command Line The in-line edit mode enables you to edit a previous command on the current command line. Use vi commands to move and edit the previous command line. Command Format set [-+]o vi Using set -o vi turns command-line editing on, while set +o vi turns it off. Once the editing has been turned on, pressing the Esc key activates the in-line editor. You then have access to vi commands. 12 Basic Features of the Korn Shell 12-17 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D History in the Korn Shell Editing the Command Line The following vi commands can be used to edit a command line. In the above example, the user used the editing feature to change worfs to words. The Return key is pressed after all changes are made. Note – The arrow keys cannot be used to reposition the cursor during in-line editing. $ more /usr/dict/worfs /usr/dict/worfs: No such file or directory $ set -o vi (Press the Esc key and then the k key until the desired command displays then edit appropriately.) $ more /usr/dict/words Table 12-1 Command Line Edit Commands vi Command Meaning k Move backward through history list j Move forward through history list l Move to the right one character h Move to the left one character r Replace one character cw Change word x Delete one character 12 12-18 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Additional Features of the Korn Shell Table 12-2 identifies some of the features of each shell available in the Solaris 7 environment. a The C shell has a form of command-line editing called command substitution. It is not capable of editing a full line, but rather substitutes one character for another. b Covered in detail in Module 16, “System Processes & Memory Management.” The set command can be used with the ignoreeof and noclobber arguments as shown previously with command-line editing. Use set -o to turn a feature on and set +o to turn it off. Table 12-2 Solaris Shell Features Feature Bourne C Korn Use aliases No Yes Yes Support command-line editing No No a Yes Support history list No Yes Yes Ignore Control-d (ignoreeof) No Yes Yes Separate initialization file from .profile No Yes Yes Have job control (ability to move job to and from the background and foreground for processing; ability to suspend a job) b No Yes Yes Logout file No Yes No Protect files from overwriting (noclobber) No Yes Yes 12 Basic Features of the Korn Shell 12-19 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the Basic Features of the Korn Shell Exercise objective – In this exercise, you will use the Korn shell features discussed in this module to create aliases; display, re-execute, and edit previously entered commands; and customize your .kshrc file. Tasks Be sure you do the following exercises in the Korn shell: 1. Create an alias that changes to your home directory and then prints the absolute pathname of the directory. 2. Test the alias created in step 1. 3. Create an alias called del that will prompt for confirmation whenever you delete a file. 4. Test the alias created in step 3 by deleting the memo file in the ~/practice directory. 5. Create an alias that will display a long listing of directory contents. 6. Type the command that displays your list of aliases. 7. Delete the alias called del. 8. Change to your home directory. Be sure you are in the Korn shell. 9. Type an ls command and the appropriate option that will display the file and directory names of any length that end with the letter “s”. 10. Display the history list and then re-execute the previous ls command. 11. Use the ls command and output redirection to create a file called dir.list. 12. Use the cat command to display the file created in step 11. 12 12-20 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the Basic Features of the Korn Shell Tasks 13. Use in-line editing (set -o vi) to change the cat command in the previous command to ls. 14. Create an alias called star that will change the current directory to ~/dir3/planets and list its contents. 15. Alter your PATH statement in the appropriate initialization file to include your personal binary directory. Workshop Labs Use what you have learned so far in this course to work through the following: 1. Create a .kshrc file, if one does not already exist. Put the following into it: a. A feature that keeps the system from overwriting a file during redirection. b. Two aliases to shortcut commands that you use frequently. c. A feature that sets command-line editing for future login sessions. 2. Make sure the appropriate variable is in the .profile file so that the .kshrc is read when you log in to the system. 3. Have the system reread the two initialization files and test your new aliases and PATH statement. 12 Basic Features of the Korn Shell 12-21 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the Basic Features of the Korn Shell Exercise Summary Discussion – Take a few minutes to discuss what experiences, issues, or discoveries you had during the lab exercises. ✓ Manage the discussion here based on the time allowed for this module, which was given in the “About This Course” module. If you find you do not have time to spend on discussion, then just highlight the key concepts students should have learned from the lab exercise. ● Experiences ✓ Ask students what their overall experiences with this exercise have been. You might want to go over any trouble spots or especially confusing areas at this time. ● Interpretations ✓ Ask students to interpret what they observed during any aspects of this exercise. ● Conclusions ✓ Have students articulate any conclusions they reached as a result of this exercise experience. ● Applications ✓ Explore with students how they might apply what they learned in this exercise to situations at their workplace. 12 12-22 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the Basic Features of the Korn Shell Exercise Solutions Be sure you do the following exercises in the Korn shell. 1. Create an alias that changes to your home directory and then prints the absolute pathname of the directory. $ alias home=’cd;pwd’ 2. Test the alias created in step 1. $ home 3. Create an alias called del that will prompt for confirmation whenever you delete a file. $ alias del=’rm -i’ 4. Test the alias created in step 3 by deleting the memo file in the ~/practice directory. $ del ~/practice/memo 5. Create an alias that will display a long listing of directory contents. $ alias long=’ls -l’ 6. Type the command that displays your list of aliases. $ alias 7. Delete the alias called del. $ unalias del 8. Change to your home directory. $ cd 12 Basic Features of the Korn Shell 12-23 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the Basic Features of the Korn Shell Exercise Solutions 9. Type an ls command and the appropriate option that will display the file and directory names of any length that end with the letter “s”. $ ls -d *s 10. Display the history list and then re-execute the previous ls command. $ history $ r command_number or $ rl 11. Use the ls command and output redirection to create a file called dir.list. $ ls > dir.list 12. Use the cat command to display the file created in step 11. $ cat dir.list 13. Use in-line editing (set -o vi) to change the cat command in the previous command to ls. $ set -o vi Press the Esc key and then press k twice. Change cat to ls. 14. Create an alias called star that will change the current directory to ~/dir3/planets and list its contents. $ alias star=’cd ~/dir3/planets;ls’ 15. Alter your PATH statement in the appropriate initialization file to include your personal binary directory. $ vi .profile add a line that reads PATH=$PATH:$HOME/bin [...]... issued commands Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 12 Think Beyond What advantages/disadvantages can you think of for changing your prompt and adding aliases? In your work environment, are any aliases already preset by your system administrator? Basic Features of the Korn Shell 12-25 Copyright 1999 Sun Microsystems,... request id is staffp-8 (1 file(s)) $ 13-4 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Displaying Printer Status and Queues Use the lpstat command to display the status of the printer queue Command Format lpstat [-options] Options -p Prints status of all printers -o Prints the status of all output requests -d Prints which... exercise experience q  Interpretations Ask students to interpret what they observed during any aspects of this exercise q  Experiences Applications Explore with students how they might apply what they learned in this exercise to situations at their workplace Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Exercise: Printing... provides details regarding that printer 13-12 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Viewing Printer Properties You can change the label name associated with the printer using the Printer Properties window Also, if the printer has been disabled, or there is a problem with the printer, this window will display information... default printer) 13-10 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Printer Jobs Printer Jobs Printing 13-11 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Viewing Printer Properties When the printer icon is selected, you can display the properties of your default printer... request-ID Command Format cancel request-ID Canceling a Print Request $ lpstat staffp staffp-2 user2 551 Dec 10 16:45 on staffp staffp-3 user3 632 Dec 10 16: 47 $ cancel staffp-3 request "staffp-3" cancelled $ 13-8 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Removing a Print Request Canceling a Print Request Use the cancel... display information regarding the problem Printing 13-13 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Setting Printer Job Options The View ®Set Options menu choice enables you to configure how the print queue requests are displayed 13-14 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August... number of copies of the file to be printed q Set a banner title (which will be displayed in the Print Manager window alongside the print object) q Select specific pages to print q Designate which UNIX print command options should be used as an alternative to the default print command Once the Print button is selected, the file will be sent to the appropriate printer queue 13-16 Fundamentals of Solaris 7 Copyright... cancel your own print requests Printing 13-19 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Canceling a Print Request If you attempt to cancel another user’s print job from the Print Manager, the print job will reappear in the printer queue 13-20 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services... highlight the key concepts students should have learned from the lab exercise q  Ask students what their overall experiences with this exercise have been You might want to go over any trouble spots or especially confusing areas at this time q  13-22 Conclusions Have students articulate any conclusions they reached as a result of this exercise experience q  Interpretations Ask students to interpret what . history 27 27 cd /usr/dict 28 history 23 29 history 22 24 30 pwd 31 pwd 32 cd ~ $ r 27 cd /usr/dict $ pwd /usr/dict $ pwd /usr/dict $ r p pwd /usr/dict 12 12-16 Fundamentals of Solaris 7 Copyright. Applications ✓ Explore with students how they might apply what they learned in this exercise to situations at their workplace. 12 12-22 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc identifies some of the features of each shell available in the Solaris 7 environment. a The C shell has a form of command-line editing called command substitution. It is not capable of editing a

Ngày đăng: 13/08/2014, 02:23

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan