Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 63 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
63
Dung lượng
349,48 KB
Nội dung
10 Exercise: Using Bourne and Korn Shell Variables Exercise Solutions Determine how your current PATH variable is set $ echo $PATH Add the /usr/ucb directory to your path and export the variable $ PATH=$PATH:/usr/ucb; export PATH 10-20 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 10 Check Your Progress Before continuing on to the next module, check that you are able to accomplish or answer the following: u Set and unset shell and environment variables for the Bourne and Korn shells u Change the PATH environment variable for the Bourne and Korn shells u Use the which command to determine which version of a command is being used u Use the whereis command to search for instances of a command on a system Bourne and Korn Shell Variables 10-21 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 10 Think Beyond Setting variables at the command line every time you log in can be tedious How could you make these variable definitions a permanent part of your environment? How might a system administrator define variables for all users on a system? 10-22 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D Initialization Files 11 Objectives Upon completion of this module, you should be able to: q Name the different initialization files for the Bourne, Korn, and C shells q Identify the initialization file used by the Common Desktop Environment q Define the purpose of initialization files q Describe where the initialization files are located and what types of settings can be defined q Set the ENV variable to enable the kshrc file to be read 11-1 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 Relevance Present the following question to stimulate the students and get them thinking about the issues and topics presented in this module While they are not expected to know the answer to the question, the answer should be of interest to them and inspire them to learn the content presented in this module Discussion – Certain types of information, such as your default printer, are set each time you log in What other types of customizable settings could be set at the beginning of each session? Additional Resources Additional resources – The following references can provide additional details on the topics discussed in this module: q q 11-2 Solaris User’s Guide, Part Number 802-6499 Solaris Advanced User’s Guide to System and Network Tasks, Chapters and 3, Part Number 801-4415-10 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 Features of Initialization Files Overview Initialization files contain a series of commands and variable settings that are executed when a shell is started These files customize the environment for the system and the user There are two levels of initialization files The first level is systemwide System initialization files are maintained by a system administrator and reside in the /etc directory Initialization Files 11-3 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 Features of Initialization Files Overview The second level is user-specific initialization files that reside in a user’s home directory These files are listed in Table 11-1 Table 11-1 User-Specific Initialization Files Shell System-Wide (Read First) User-Specific (Read Second) Bourne /etc/profile $HOME/.profile Korn /etc/profile $HOME/.profile ENV=$HOME/.kshrc;export ENV $HOME/.kshrc C /etc/.login $HOME/.login $HOME/.cshrc $HOME/.logout Note – ENV is a variable that is set in the profile file to direct the system to read an alternate initialization file $HOME is the user’s home directory When a predefined environment variable is placed in one of the system-wide initialization files, it is recognized globally in any shell or subshell Users can customize many of these variables for their own environment by placing them in the initialization files in their home directory To make the customizations available to all subsequent shells, the variable must be exported Unlike variables, commands cannot be exported If commands are used in the initialization files, they must be placed in the secondary initialization files in order to be read each time a subshell is opened 11-4 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 Features of Initialization Files The /etc/profile Script When a Bourne or Korn shell user logs in, the system reads the /etc/profile file first, and then it reads the user’s profile file, and, for Korn shell users, the kshrc file This means that the user’s preferences for variable settings can override the default settings that appear in the /etc/profile file The /etc/profile file: q Exports environment variables such as LOGNAME for login name q Exports PATH for the default command path q Sets the variable TERM for the default terminal type q Displays the contents of the /etc/motd file q Sets the default file creation permissions q Checks if you have mail and will print a mail message upon login This file is maintained by the system administrator Initialization Files 11-5 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 User-Specific Initialization Files Login Sequence When you log in to your system, the system and user’s initialization files for the appropriate shell are read, and the tasks defined in the initialization files are executed The initialization files provide great flexibility to the user for customizing their environment Generally, these files are set up as templates by the system administrator, and then modified by the user 11-6 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 11 User-Specific Initialization Files Login Sequence The user-specific initialization file(s) are stored in the home directory of the user These initialization files can perform all or part of the following: q Set the default prompt q Define the default printer q Set default permissions q Set the default terminal type used by vi and other tools q Tell the shell where to look for new mail q Set noclobber to prevent overwriting of files during redirection q Set the command path to the user’s specification q Set up custom commands Initialization Files 11-7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D Printing 13 Objectives Upon completion of this module, you should be able to: q Use command-line commands to print a file, check print queue status, and cancel a print request q Print using the Print Manager in CDE q Determine and change the default printer q Set print options q Demonstrate the major functions of the Print Manager 13-1 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Relevance Present the following question to stimulate the students and get them thinking about the issues and topics presented in this module While they are not expected to know the answer to the question, the answer should be of interest to them and inspire them to learn the content presented in this module Discussion – What printing-related tasks you need to besides sending a single file to a printer? 13-2 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Command Line Printing Printing of ASCII text or PostScript™ files can be done from the command line Do not use this method to print data files (files created in applications like FrameMaker) or binary files The function of the lp command is to queue data for printing The Solaris computing environment supports the lp print spooler Command Format lp [ -options] [filename(s)] Options -d Specifies the desired printer (If you are printing to your default printer, the -d option is not necessary.) -o nobanner Specifies that banner page is not to be printed -n Prints a specified number of copies -m Sends mail message to user after job is complete Printing 13-3 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Printing a File Sending Files to a Printer Print the file feathers in your home directory on the default printer $ lp ~/feathers request id is printer1-7 (1 file(s)) $ Use the -d option to specify another printer (if one is available) $ lp -d staffp ~/feathers request id is staffp-8 (1 file(s)) $ 13-4 Fundamentals of Solaris 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 printer is the system default -t Prints complete status information for all printers -s Prints a status summary for all printers -a Prints which printers are accepting requests Printing 13-5 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Displaying Printer Status and Queues Note – When a print request has been sent to the printer, the output of lpstat may show the print request as filtered (This is not the case in the lab environment for this course.) Filtering indicates a print request is in the process of printing The name of the print request does not appear when the lpstat command is used Displaying the Status of All of Your Output Requests $ lpstat -o printer1-7 user2 391 Dec 10 16:30 on printer1 staffp-2 user2 551 Dec 10 16:45 filtered $ Displaying Requests on a Specific Printer’s Queue $ lpstat staffp staffp-2 user2 551 Dec 10 16:45 staffp-3 user3 632 Dec 10 16:47 $ Determining the Status of All Configured Printers $ lpstat -t scheduler is running system default destination: printer1 system for printer1: venus system for staffp: mars printer1 accepting requests since Wed May 08:20:00 EST 1998 staffp accepting requests since Mon May 25 09:43 EST 1998 $ 13-6 Fundamentals of Solaris Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Displaying Printer Status and Queues Determining Which Printers Are Configured on Your System $ lpstat -s scheduler is running system default destination: printer1 system for printer1: venus system for staffp: mars $ Displaying Which Printers Are Accepting Requests $ lpstat -a printer1 accepting requests since Wed May 08:20:00 EST 1998 staffp accepting requests since Mon May 25 09:43:19 PST 1998 $ Printing 13-7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Removing a Print Request The cancel command enables you to cancel print requests previously sent with the lp command To this, you must first use the lpstat command to identify the 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 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 -u username (login ID) to remove all requests owned by you $ cancel -u user2 request "staffp-2" cancelled $ Note – You cannot remove another user’s print request Only the superuser can remove a print request sent by another user When using the CDE Printer Manager, it appears you can cancel another’s print job, but the job is immediately reinstated Printing 13-9 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 13 Printer Jobs The Printer Jobs window displays a list of the current printer and any outstanding print requests in the print queue Only one printer icon will be displayed in the Printer Jobs window This represents the printer chosen by the user (which may or may not be the same as the system default printer) 13-10 Fundamentals of Solaris 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 by choosing the Selected ® Properties menu option A window will be displayed which provides details regarding that printer 13-12 Fundamentals of Solaris 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 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 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D ... 11-2 Solaris User’s Guide, Part Number 80 2-6499 Solaris Advanced User’s Guide to System and Network Tasks, Chapters and 3, Part Number 80 1-4415-10 Fundamentals of Solaris Copyright 1999 Sun Microsystems,... front of) the line reading DTSOURCEPROFILE=true 11-10 If DTSOURCEPROFILE line is commented out, none of the initialization files are read (with the exception of dtprofile) Fundamentals of Solaris. .. 12-2 Solaris User’s Guide, Part Number 80 2-6499 Solaris Advanced User’s Guide to System and Network Tasks, Chapters and 3, Part Number 80 1-4415-10 Fundamentals of Solaris Copyright 1999 Sun Microsystems,