1. Trang chủ
  2. » Công Nghệ Thông Tin

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

68 208 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 68
Dung lượng 391,67 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

History in the Korn ShellRe-Executing Commands Ther is a custom command alias in the Korn shell.. Exercise: Using the Basic Features of the Korn ShellExercise objective – In this exercis

Trang 1

History in the Korn Shell

Re-Executing Commands

Ther 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 thercommand is the history line number of

a particular command, or a letter indicating the most recent command

in thehistorylist that started with that letter

Trang 2

History in the Korn Shell

Trang 3

History in the Korn Shell

Editing the Command Line

The in-line edit mode enables you to edit a previous command on thecurrent command line Usevicommands to move and edit the

previous command line

Command Format

set [-+]o vi

Usingset -o viturns command-line editing on, whileset +o vi

turns it off Once the editing has been turned on, pressing the Esc keyactivates the in-line editor You then have access tovicommands

Trang 4

History in the Korn Shell

Editing the Command Line

The following vicommands can be used to edit a command line Inthe 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

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

Trang 5

Additional Features of the Korn Shell

Table 12-2 identifies some of the features of each shell available in theSolaris 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.

bCovered in detail in Module 16, “System Processes & Memory Management.”

Thesetcommand can be used with theignoreeofand noclobber

arguments as shown previously with command-line editing Use

set -oto turn a feature on andset +oto turn it off

Table 12-2 Solaris Shell Features

Support command-line editing No Noa YesSupport history list No Yes YesIgnore Control-d (ignoreeof) No Yes YesSeparate initialization file from

Protect files from overwriting(noclobber)

No Yes Yes

Trang 6

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 thenprints the absolute pathname of the directory

2 Test the alias created in step 1

3 Create an alias called delthat will prompt for confirmationwhenever you delete a file

4 Test the alias created in step 3 by deleting thememofile in the

~/practicedirectory

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 anlscommand and the appropriate option that will displaythe file and directory names of any length that end with the

Trang 7

Exercise: Using the Basic Features of the Korn Shell

Tasks

13 Use in-line editing (set -o vi) to change the catcommand inthe previous command tols

14 Create an alias called starthat will change the current directory

to~/dir3/planetsand list its contents

15 Alter yourPATHstatement in the appropriate initialization file toinclude your personal binary directory

b Two aliases to shortcut commands that you use frequently

c A feature that sets command-line editing for future loginsessions

2 Make sure the appropriate variable is in the.profilefile so thatthe.kshrcis read when you log in to the system

3 Have the system reread the two initialization files and test yournew aliases andPATHstatement

Trang 8

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.

Explore with students how they might apply what they learned in this exercise to

situations at their workplace.

Trang 9

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 thenprints the absolute pathname of the directory

$ alias del=’rm -i’

4 Test the alias created in step 3 by deleting thememofile in the

Trang 10

Exercise: Using the Basic Features of the Korn Shell

Press the Esc key and then press k twice Changecatto ls

14 Create an alias called starthat will change the current directory

to~/dir3/planetsand list its contents

$ alias star=’cd ~/dir3/planets;ls’

15 Alter yourPATHstatement in the appropriate initialization file toinclude your personal binary directory

$ vi profile

add a line that reads

PATH=$PATH:$HOME/bin

Trang 11

Check Your Progress

Before continuing on to the next module, check that you are able toaccomplish or answer the following:

❑ Use basic shell quoting

❑ Customize the Korn shell

❑ Customize commands in the Korn shell using thealiascommand

❑ Review previously executed commands in the Korn shell using the

historycommand

❑ Set the command-line editor and edit previously issuedcommands

Trang 12

Think Beyond

What advantages/disadvantages can you think of for changing yourprompt and adding aliases? In your work environment, are any aliasesalready preset by your system administrator?

Trang 14

Upon completion of this module, you should be able to:

● Use command-line commands to print a file, check print queuestatus, and cancel a print request

● Print using the Print Manager in CDE

● Determine and change the default printer

● Set print options

● Demonstrate the major functions of the Print Manager

Trang 15

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 do you need to do besides

sending a single file to a printer?

Trang 16

Command Line Printing

Printing of ASCII text or PostScript™ files can be done from thecommand line Do not use this method to print data files (files created

in applications like FrameMaker) or binary files

The function of the lpcommand is to queue data for printing

The Solaris computing environment supports the lpprint 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 notnecessary.)

-o nobanner Specifies that banner page is not to be printed

-n Prints a specified number of copies

Trang 17

Printing a File

Sending Files to a Printer

Print the filefeathers in your home directory on the default printer

Trang 18

Displaying Printer Status and Queues

Use the lpstatcommand 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

Trang 19

Displaying Printer Status and Queues

Note – When a print request has been sent to the printer, the output of

lpstatmay 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 notappear when thelpstatcommand is used

Displaying the Status of All of Your Output Requests

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 6 08:20:00 EST 1998

staffp accepting requests since Mon May 25 09:43 EST 1998

$

Trang 20

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

printer1 accepting requests since Wed May 6 08:20:00 EST 1998

staffp accepting requests since Mon May 25 09:43:19 PST 1998

$

Trang 21

Removing a Print Request

Thecancelcommand enables you to cancel print requests previouslysent with thelpcommand To do this, you must first use thelpstat

command to identify therequest-ID

Trang 22

Removing a Print Request

Canceling a Print Request

Use the cancel -uusername (login ID) to remove all requestsowned 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 Whenusing the CDE Printer Manager, it appears you can cancel another’sprint job, but the job is immediately reinstated

Trang 24

Printer Jobs

Printer Jobs

Trang 25

Viewing Printer Properties

When the printer icon is selected, you can display the properties ofyour default printer by choosing the Selected ➤ Properties menuoption A window will be displayed which provides details regardingthat printer

Trang 26

Viewing Printer Properties

You can change the label name associated with the printer using thePrinter Properties window Also, if the printer has been disabled, orthere is a problem with the printer, this window will display

information regarding the problem

Trang 27

Setting Printer Job Options

The View ➤Set Options menu choice enables you to configure how theprint queue requests are displayed

Trang 28

Setting Printer Job Options

You can also set the time interval that the Print Manager uses to checkthe current print queue, as shown in the following illustration:

Trang 29

Printing From the File Manager

You can print a file from the File Manager window by dragging anddropping it on the Print Manager icon or dropping the object directlyinto the Print Manager window

Once the file object has been dropped into the Print Jobs window,another window will be displayed in which you can:

● Designate an alternative printer to print the file

● Designate the number of copies of the file to be printed

● Set a banner title (which will be displayed in the Print Managerwindow alongside the print object)

● Select specific pages to print

● 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

Trang 30

Printing From the File Manager

Trang 31

Displaying the Banner Page Title

When a banner page title has been entered for a print request, that textwill be displayed in the Print Manager window The name of the userwho submitted the print request will be displayed below the bannertext

Trang 32

Canceling a Print Request

To cancel a print request, you must first select the Print Managerdisplay object corresponding to that print request

Once the object has been selected, use the Selected ➤ Cancel menuoptions

You will be asked to confirm that you want to have the print requestcancelled, as shown in the following illustration Again, you can onlycancel your own print requests

Trang 33

Canceling a Print Request

If you attempt to cancel another user’s print job from the PrintManager, the print job will reappear in the printer queue

Trang 34

Exercise: Printing Files

Exercise objective – In this exercise you will use the print commands

learned in this module to print a file

Tasks

Complete or answer the following:

1 Files can be printed by dragging a File Manager file object on tothe Default Printer icon (on the Front Panel) or into the PrinterJobs window, true or false?

6 Using thelpcommand, print thedantefile on the default printer

7 From the command line, check the status of the previously sentprint request

Trang 35

Exercise: Printing Files

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.

Explore with students how they might apply what they learned in this exercise to

situations at their workplace.

Trang 36

Exercise: Printing Files

Exercise Solutions

1 Files can be printed by dragging a File Manager file object on tothe Default Printer icon (on the Front Panel) or into the PrinterJobs window, true or false?

False; A user can cancel his or her own job.

4 From the command line, what command would you use to see if aprinter was accepting requests?

Trang 37

Check Your Progress

Before continuing on to the next module, check that you are able toaccomplish or answer the following:

❑ Use command-line commands to print a file, check print queuestatus, and cancel a print request

❑ Print using the Print Manager in CDE

❑ Determine and change the default printer

❑ Set print options

❑ Demonstrate the major functions of the Print Manager

Trang 38

Think Beyond

What kinds of printers do you have access to in your environment?For what kinds of jobs would you use a printer other than your defaultprinter?

Trang 40

Upon completion of this module, you should be able to:

● Describe some advantages of using file systems

● List the inode number of a file

● Link files using hard and symbolic links

● Employ the findcommand to locate files by specific criteria

● Search for text within a document using the grepcommand

● Identify which users are logged on to your system

● Switch to a new user ID and identify the user ID you are currentlyusing

● Identify your effective and real UID when switching users

● Use thesortcommand to sort ASCII files in alphabetical andnumerical order

● Use thesortcommand to perform multilevel sorts on ASCII data

Trang 41

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 utilities do you need for daily computer use?

Do you need to search for items, such as files? What other searches doyou need to do?

Additional Resources

Additional resources – The following references can provide

additional details on the topics discussed in this module:

Solaris Advanced User’s Guide, Part Number 801-6615-10

Solaris System Administrator AnswerBook

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