Tải bản đầy đủ (.pdf) (51 trang)

Sun Fundamentals of Solaris 7 EU-118 Student Guide With Instructor Notes phần 4 potx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (266.3 KB, 51 trang )

4
4-18 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Exercise: Getting Help
Exercise objective – In this lab you will practice using the help
functions available with CDE and the command-line man pages.
Tasks
Complete the following steps:
1. Open a Help Viewer window by clicking on the appropriate Front
Panel icon.
2. In the Help Viewer window, select Index and choose All Volumes.
3. Find information on how to play an audio file. After reading this
information, open the Audio player from the Workspace menu
and play the /usr/demo/SOUND/sounds/spacemusic.au audio
file.
4. Display the on-line manual (man) page for the ls command.
5. Display the on-line manual pages for the passwd command and
the passwd file.
6. Find the on-line manual page that describes how to clear the
terminal screen (use the keyword “clear”).
7. Display the Help subpanel and determine whether AnswerBook2
has been made available on your system.
8. If you do have AnswerBook2, invoke it from the subpanel and
look through the Solaris CDE User’s Guide.
9. When you are finished, close the AnswerBook2 window.
4
Getting Help 4-19
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Exercise: Getting Help
Workshop Labs
Use what you have learned so far in this course to work through the


following:
1. Using the Calendar Manager, add an appointment for lunchtime
on every Wednesday for the next month. Have the system send
you an email message 30 minutes before the appointment and
place a reminder on your desktop 10 minutes before the
appointment. Use any version of help you need to perform this
task.
2. What meaning would an ampersand “&” in the gcos field of a
password file entry carry for the system?
4
4-20 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Exercise: Getting Help
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.
4
Getting Help 4-21
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Exercise: Getting Help
Exercise Solutions
4. Display the on-line manual (man) page for the ls command.
man ls
5. Display the on-line manual pages for the passwd command and
the passwd file.
man passwd
man -s 4 passwd
6. Find the on-line manual page that describes how to clear the
terminal screen (use the keyword “clear”).
man -k clear
4
4-22 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Check Your Progress
Before continuing on to the next module, check that you are able to
accomplish or answer the following:
❑ Describe how to obtain help from the Front Panel
❑ Describe how to obtain application-specific help
❑ Invoke the Help Viewer from the Front Panel
❑ Invoke help from an application window

❑ Display on-line manual pages, including different sections of the
manual
❑ Search the on-line manual pages by keyword
4
Getting Help 4-23
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Think Beyond
Which type of help would you be most likely to use? Would this
change depend on what you needed help on?
5-1
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
AccessingFilesandDirectories
5
Objectives
Upon completion of this module you should be able to:
● Contrast absolute and relative pathnames
● Access files and directories within the file structure using absolute
and relative pathnames
● Identify and describe the parts of a command line
● Access files and directories within the file structure using
pathname abbreviations
● List the contents of directories and their file types
● Identify various metacharacters
● Enter more than one command on a single command line
● Demonstrate the use of wildcard characters
5
5-2 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
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 – How does the Solaris system know how to find files and
directories?
Additional Resources
Additional resources – The following reference can provide additional
details on the topics discussed in this module:
● Solaris User’s Guide, Part Number 802-6499
5
Accessing Files and Directories 5-3
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
File System Structure
Figure 5-1 shows a typical Solaris system file structure; you will refer
to this again later in this course.
Figure 5-1 Solaris File System Structure
user2
dir1
dir2
dir3
dir4
practice
file1
file4
fruit2
file3
fruit
file2

dante_1
dante
trees
fruit
coffees
beans
nuts
recipes
beans
notes
planets
mars
pluto
flowers
home
/
5
5-4 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Pathnames
A pathname uniquely identifies a particular file or directory by
specifying its location. Pathnames are similar to a road map or a set of
directions that tells you how to get from one place in the directory
hierarchy to another.
Note – Depending on the setup of your system, home directories can
be found in either /home or /export/home. For the purposes of this
discussion, /home is used.
The slashes within the pathnames are delimiters between object
names. A slash in the first position represents the / (root) directory.
For example:

/home/user2/dir1/coffees
Figure 5-2 Pathname With Delimiters
Delimiters
root directory
5
Accessing Files and Directories 5-5
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Notes

The concept of pathnames is critical to the student’s understanding of how to access files
in the file structure. Pathnames identify every file in the file structure.

Briefly describe the Solaris file structure in terms of a hierarchy of directories,
subdirectories, and files. The file cabinet analogy works well with the Solaris computing
environment file structure. If the file cabinet analogy does not work for everyone, you
might draw a “tree” structure. Use root (/) and some directories to illustrate the root,
branches, limbs, and so on.

At some point it should be noted that this is not what the students’ file structure will look
like back at the office. In other words, the file names, and possibly the location of the
home directory, will be different in their work environment. The structure shown is an
example only.

If the classroom lab is set up in such a way that students’ home directories are under
/export/home
, explain that when home directories reside on the local system they are put,
by convention, under
/export/home
. When home directories are provided by a home
directory server, by convention, they are found under

/home
.
5
5-6 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Pathnames
There are two types of pathnames: absolute and relative.
Absolute Pathname
An absolute pathname specifies a file or directory in relation to the entire
Solaris file hierarchy. The hierarchy begins at the / (root) directory.
Absolute pathnames always:
● Start at the root (/) directory and list each directory along the path
to the destination file (or directory)
● Use a slash (/) between each directory name in the path to indicate
different directories
5
Accessing Files and Directories 5-7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Pathnames
Absolute Pathname
Refer to Figure 5-1 on page 5-3 for a visual representation of the
following pathnames:
● Absolute pathname to user2
/home/user2
● Absolute pathname to dir1
/home/user2/dir1
● Absolute pathname to coffees
/home/user2/dir1/coffees
5
5-8 Fundamentals of Solaris 7

Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Pathnames
Relative Pathname
A relative pathname describes the location of a file or directory as it
relates to the current directory. If you are in a directory and you want
to move down the directory tree, it is not necessary to type the
absolute pathname. You can just type the path starting with the name
of the next directory in the directory structure. If a pathname does not
begin with a slash, it is a relative pathname.
Relative pathnames are useful because they are shorter than absolute
pathnames.
5
Accessing Files and Directories 5-9
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Pathnames
Relative Pathname
Use Figure 5-1 on page 5-3 to support these examples:
● The current directory
/home
● Relative pathname to user2
user2
● Relative pathname to dir1
user2/dir1
● Relative pathname to coffees
user2/dir1/coffees
5
5-10 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Command-Line Syntax
When using a terminal window, a shell prompt appears on the screen.

For the Bourne and Korn shells, the shell prompt for a user is a dollar
sign ($). For a C shell user, the prompt is a percent sign (%).
At the shell prompt, you can type commands. Commands are
instructions which tell the system to perform an action.
The general format for Solaris 7 commands is:
command
Executable (specifies what you want the system to do)
options
Modify the executable (specifies how you want the
command run)
argument
File or directory, including the path name, or text. If a
pathname is not specified for a file or directory
argument, then the operating system will use the
current directory.
$
command
[
option(s)
][
argument
[
s
]]
5
Accessing Files and Directories 5-11
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Command-Line Syntax
● A space must be used as a delimiter between each part of the
command line.

● Up to 256 characters can be entered on a single command line.
● Many commands do not require all three parts.
Some examples are:
$ cal (Command only)
$ cal 1987 (Command and argument)
$ date (Command only)
$ date -u (Command and option)
$ banner "hi there" (Command and argument)
5
5-12 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Changing Directories Using the cd Command
Files you need to access are often stored in subdirectories below your
home directory. Because of the way in which a UNIX file system is set
up, it is often desirable to change directory locations.
Use the cd command to change to a new current directory. This
command, like all UNIX commands, accepts both absolute and relative
pathnames.
Command Format
cd [
directory_name
]
5
Accessing Files and Directories 5-13
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Changing Directories Using the cd Command
Moving Around the Directory Hierarchy
You can use cd with:
▼ An absolute pathname
$ cd /home

▼ A relative pathname
$ cd user2/dir1
Use the cd command without a directory name to return to your home
directory.
$ cd
5
5-14 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Displaying the Current Directory Using the pwd Command
Remembering which directory you are currently working in is often
difficult. Use the pwd (print working directory) command to display
the absolute pathname of your current directory.
Command Format
pwd
5
Accessing Files and Directories 5-15
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Displaying the Current Directory Using the pwd Command
Determining Your Current Directory
$ pwd
/home/user2
$
$ cd /home
$ pwd
/home
$
$ cd
$ cd practice
$ pwd
/home/user2/practice

$

Directories always contain a link to their parent directory ( ) and a link to themselves (.).
5
5-16 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Displaying the Current Directory Using the pwd Command
Pathname abbreviations are a form of shorthand when moving
between or referring to directories.
Table 5-1 Pathname Abbreviations

The symbol ~+ refers to the current working diretory (
$PWD
). It is used mostly when
writing scripts.
Symbol Meaning
. Current (working) directory
Parent directory; the directory directly
above the current directory
~ User’s home directory (Korn and C
shells)
~- The full path to the previous working
directory (Korn shell only)
~
logname
The home directory of the user
specified by
logname
5
Accessing Files and Directories 5-17

Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Displaying the Current Directory Using the pwd Command
Use pathname abbreviations with the cd command to move around
the file structure. For example:
$ pwd
/home/user2/dir1
$ cd
$ pwd
/home/user2
$ cd /
$ pwd
/
$ cd ~/practice
$ pwd
/home/user2/practice
$ cd ~-
$ pwd
/
$ cd ~guest
$ pwd
/home/guest
5
5-18 Fundamentals of Solaris 7
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D
Using the ls Command
To determine the contents of a directory, use the ls command. This
command will display a listing of all files and directories within
specified directories. If no pathname is given as an argument, ls will
display the contents of the current directory.
Command Format

ls [
-option(s)
][
pathname
[s]]

×