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 n
Trang 1Setting 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 2Printing 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
Trang 3Printing From the File Manager
Trang 4Displaying 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 5Canceling 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 6Canceling 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 7Exercise: 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 8Exercise: 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 9Exercise: 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 10Check 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 11Think 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 13Upon 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 14✓ 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
Trang 15File Systems
When the UNIX operating system was first developed, hard diskscould store what is now considered a very small amount of data.When disks larger than 300 Mbytes arrived on the market theoperating system could not address such a large amount of space This
necessitated the development of logical partitions of the hard drive to
allow the kernel to access smaller, addressable parts of the drive
Trang 16File Systems
Today, with hard drives being sold with up to a Tbyte or more of space
on them, the kernel can access all available space Despite this, theconvention of partitioning a hard drive into logical partitions haspersisted for various reasons Partitioning allows an administrator tofunctionally organize data so that user files are on a different logicalpartition than executables or applications One of the main advantages
to this is that daily backups can be done only to those partitions onwhich the data changes frequently, without having to back up allinformation on the disk Logical partitioning also cuts down on seektime: if the disk is partitioned, when a user specifies a file to search for
or a directory to change to, the name of the directory gives the kernelinformation about where the information is stored This prevents thesystem from having to seek the information over the entire disk
These logical partitions are referred to as file systems They are
transparent to a user and therefore appear to be just part of thedirectory hierarchy The most common file systems on a UNIX systemare/usr, where binary and executables are stored,/opt, where thirdparty applications are usually located, and root (/), where the filesthat pertain to the operation of the system are kept
Trang 17Inode Numbers
Inode numbers are identifiers of a file on a file system Similar to the
way in which a passport number is unique for each person in acountry, an inode number is unique for each file in a file system
Each file and directory has an inode number assigned to it by thesystem These numbers can be seen by using the following ls
command:
$ ls -i ~
12110 dante 68349 dir3 12118 file3
12115 dante_1 68451 dir4 12119 file4
67773 dir1 12169 file1 68552 practice
The numbers to the left of the file name are the inode numbers These
are sometimes referred to as index numbers, as the kernel keeps an
index of the files and directories by the inode number and cantherefore refer to them faster
Trang 18Linking Files and Directories
Links
Links are used to create alternate names or aliases for files and
directories on a system In this way, different users can refer to thesame file or directory by names they are more comfortable with ornames that are shorter Many system administrators set up links tocommands, giving them names more familiar to users of differentoperating systems
There are two kinds of links, hard and symbolic (or soft).
Trang 19Linking Files and Directories
Links
Hard Links
Hard links are used to link files on the same file system Files that arehard linked share the same inode number and, therefore, refer to thesame data on the hard disk Hard links are not used to link directoriesand cannot cross file systems, as the inode number is only unique forthat file in its current file system A completely different file may havethe same inode number on a different file system
Trang 20Linking Files and Directories
Links
Hard Links
The output of thels -lcommand shows a link count following thepermissions This is a count of how many files are hard linked to thesame inode number as the file listed
$ ls -l ~
-rw - 1 torey staff 1320 Oct 19 dante-rw - 1 torey staff 368 Oct 19 dante_1drwx x x 5 torey staff 512 Oct 19 dir1drwx x x 4 torey staff 512 Oct 19 dir2
<output omitted>
The link count on directories includes a link to the current directory (.)and from the parent ( ) directory, and a number for each file or
subdirectory included in the directory
The structure of a hard link is as follows:
All hard-linked files share the same inode number and therefore thesame data This data can be displayed using an appropriate command;for example,cator more In the case of hard links, as long as one filethat refers to the inode number remains, the data remains available onthe system For this reason,File1andFile3could be deleted, leavingthe information referred to intact, asFile2would still exist
Note – Hard links cannot be used to link directories; only symbolic
File1 Inode number Data DisplayFile2
File3
Trang 21Linking Files and Directories
Links
Symbolic Links
Symbolic links are used for two main reasons: to link a file or directory
across file systems, or for backwards compatibility Since symbolically
linked files do not share a single inode, these links can cross filesystem boundaries There are also many cases where commands, files,
or directories that have existed as part of the UNIX operating systemfor years are given different names In order to avoid having to retrainthe multitude of UNIX users in the world, symbolic links are
employed to refer to these files by both their old and new names This
is referred to as backwards compatibility.
Trang 22Linking Files and Directories
The structure of a symbolic link is as follows:
The data contained inFile2is the absolute pathname to File1, butdisplaying eitherFile1orFile2will produce the same output If
File2is deleted, there is no effect onFile1 IfFile1is deletedFile2
will still exist, but it will point to an invalid file name and therefore be
of no practical use
File1 inode number Data DisplayFile2 inode number Absolute pathname to File1
Trang 23Linking Files and Directories
Trang 24Finding Files
Thefindcommand is one of the most powerful and useful of thecommands available to a UNIX environment user This command can
be used to find files based on specific criteria Once a file or group offiles that matches a search criterion is found, another command can beexecuted on the matching files Thefindcommand can be used formany purposes including deleting, backing up, or printing files
Trang 25Finding Files
Command Format
find path expression [action]
expression The search criteria is specified by one or more values If
more than one expression is specified,find treats thestatement as an “and” request and all listed expressionsmust be verified as true or present Many search
expressions will require a value to match and in somecases metacharacters, or wildcards, may be used for thearguments
Search Expressions Definition
-name filename Search for all files matching the specifiedfilename
Metacharacters are acceptable but will be interpretedliterally unless placed inside quotes
-type filetype Search for all files matching the specifiedfiletype
-mtime [+|-]n Search for all files whose modification time either
matches, is older than (+), or is newer than (–)ndays
-atime [+|-]n Search for all files whose access time either matches, is
older than (+), or is newer than (–) n days
-inum n Search for the files with the inode number ofn
-user loginid
-group groupid
Search for all files that match the ownership of
loginid or group of groupid
-perm mode Search for all files that match the permission setting of
mode (Octal notation only)
-size [+|-]n[c] Search for all files whose size either matches, is larger
than (+), or is smaller than (–) n Then represents 512byte blocks, or characters (bytes) if followed by ac
Trang 26Finding Files
The expressions used with thefindcommand evaluate as true orfalse
Actions
Note – Releases of the Solaris environment previous to 2.5 required the
-printaction in order to see the output from thefindcommand onthe screen
Thefindcommand has several additional features that can be used tofurther define search criteria Consult man pages for further details
Some additional features:
-exec command {} \; Theexec option must be terminated by
{ } \; which allowsfind to apply thespecified command to each file that itidentifies from the search criteria
-okcommand {} \; Interactive form of-exec This option is
used with commands that require inputfrom the user; for example,rm -i
long listing format This expression ismost commonly used in conjunction with
a redirection of output to a file in order forthe listing to be examined at a later time
-o Allows for an “or” type of criteria definition
-a Allows for an “and” type of criteria definition
Trang 27Finding Files
You can:
● Search foropenwinstarting at the/usrdirectory
● Search for files ending intifstarting at the/usrdirectory
● Search forcorefiles starting at the user’s home directory anddelete them
● Look for all files, starting at the current directory, that have notbeen modified in the last 90 days
● Find files larger than 400 blocks (512-byte blocks) starting at/etc
$ find /usr -name openwin
/usr/openwin/usr/openwin/bin/openwin
$ find /usr -name ’*tif’
/usr/openwin/demo/kcms/images/tiff/ireland.tif/usr/openwin/demo/kcms/images/tiff/new_zealand.tif
$ find ~ -name core -exec rm {} \;
$ find -mtime +90
<find output omitted>
$ find /etc -size +400
<find output omitted>
Trang 28● Find files, starting at/etc, which share the same inode number
$ find ~ -perm 777 -depth > holes
$ find -user billw -o -group staff -ls > review
$ find /etc -inum 769
<find output omitted>
Trang 29The grep Command
Use the grepcommand to search a file for a specified text string A
string is one or more characters; it can be a character, a word, or a
sentence A string can include white space or punctuation if these areenclosed in quotations
The grepcommand searches a file for a character string and prints alllines that contain that pattern to the screen Thegrepcommand can beused as a filter with other commands
Thegrepcommand is case sensitive You must match the pattern withrespect to uppercase and lowercase letters, unless you use the -i
option
Trang 30The grep Command
-i Ignore case of string when searching
-v Search for all lines that do not match string
$ grep root /etc/passwd
root:x:0:1:Super-User:/:/sbin/sh
$ ls -la | grep -i ’jun 11’
drwxr-xr-x 3 user1 staff 512 Jun 11 13:13 dir4
Trang 31Switching to Another User Account Using the su Command
You can temporarily switch to another user account to have access andprivileges to files and directories that belong to that user by using the
Command Format
su [-] username
Trang 32Switching to Another User Account Using the su Command
Using the su Command to Become Another User
customized for your user ID will also remain in effect
To switch to another UID and have the system read the new user’sinitialization files, you must use adash(-) between the command andthe new user ID
Trang 33Using the id Command
Use the idcommand to display the user name corresponding to theeffective user ID
Command Format
id [option(s)]
Trang 34Using the id Command
Displaying Your Current UID
The listing forgididentifies the user’s primary group and thegroups
listing identifies all groups to which the user belongs
$ id -a
uid=115(guest) gid=10(staff) groups=10(staff) 14(sysadmin)
$
Trang 35Using the who Command
The whocommand displays information about all users currentlylogged on the local system This command lists the user’s name,terminal line, login time, and elapsed time since the last activity on theterminal line
Trang 36Using the who Command
Use thewho -Hoption to print column headings above the regularoutput
$ who -H
NAME LINE TIMEuser2 console May 24 10:17user3 pts/4 May 24 17:36 (machine name)
Trang 37Using the who am i and whoami Commands
who am i
Thewho am icommand displays information about your real user ID(RUID) If you use the sucommand to switch from one UID to
another, thewho am icommand will display your original login UID
Thewho am icommand lists the user name, the terminal line, and thedate and time logged on
Command Format
who am i
Trang 38Using the who am i and whoami Commands
who am i
Displaying Your EUID and RUID Information
Display your effective UID (EUID)
Trang 39The sort Command
The sortcommand provides a quick and easy way for operators toorganize data in either numerical or alphabetical order This commanduses the ASCII character set as its sorting order, working from left toright on a character-by-character basis By default,sortrelies on whitespace to delimit the various fields within the data of a file Some sort
features include:
● Multilevel sorting
● Field-specific sorting
● Accepting standard input
● Producing standard output
Trang 40The sort Command
Command Format
sort [options] [input_filename]
Options
options The various options available with thesort command
enable the operator to define the type of sort to perform
as well as the field on which to begin sorting
-n Allow for a numeric sort Then can be used alone
with a dash or can follow a field reference
(+|-)n Begin (+) or end (-) the sort with the field following
thenth separator
-r Reverse the order of the sort Ther can be used
alone with a dash or can follow a field reference
(ignore case in sort order)
+nM Sort the first three characters of the field as
abbreviated month names
-d Use dictionary order Only letters, digits, and white
space are compared; all other symbols are ignored
-o filename Place any output into the filefilename