Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5929
  • 博文数量: 3
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-22 15:43
文章分类
文章存档

2011年(1)

2008年(2)

我的朋友
最近访客

分类:

2008-07-22 16:29:33

3-11. REVIEW: Check Your Understanding

1. What steps is SAM taking when performing the following tasks?

Adding a new user

De-activating a user

Modifying a user’s information

Adding a new group

Answer:

SAM is doing the following:

Adding a new user - Adding an entry to /etc/passwd and /etc/group, making a

home directory, copying default setup files, and changing the owner and group of the

login directory and default files.

De-activating a user - Replacing the user’s password field (field two in the

/etc/passwd file) with an asterisk .

Modifying a user’s information - Modifying the appropriate information in the

/etc/passwd file. Possibly changing the UID of the user’s files.

Adding a new group - Adding an entry in the /etc/group file.

2. Describe the 7 fields of the /etc/passwd file

Answer:

user_name:

encrypted password:

user_id:

group_id:

comment_field:

login_directory:

startup_program:

3. Describe the fields of the /etc/group file.

Answer:

group_name:

password:

Solutions-9 H3064S A.01

© 1999 Hewlett-Packard Company

group_id:

group_list:

4. What does it mean to set up groups? Explain.

Answer:

Groups possibly allow users access to files that other members of their group own. It allows

sharing of data amongst group members.

3-12. LAB: Hands-On Adding Users

1. Invoke SAM and add a user to your system. (You must be superuser to invoke SAM.) Use

your name as a user name. Assign the user to a group called class and give him or her the

POSIX shell.在系统中使用sam生成用户mickey,由sam选择uid。将该用户加入users组,使用默认组目录posix shell.你可以选用任何口令。

Now, exit SAM and look at the /etc/passwd and /etc/group files. Do you see the user you

added?sam/etc/passwd文件中追加了什么?/etc/group文件中有新追加的用户么?请解释!

Answer:

Use sam to add a user.

2. Add a user to the system using HP-UX commands. This time, use your partner’s name as

the user name. (If you don’t have a partner, pick any name.) Use a group called class and

give the new user the C shell.

Look at the /etc/passwd and /etc/group files. Do you see the user added? Assign a

password for the new account.

Answer:

useradd -m -s /usr/bin/csh -g class amy

passwd amy

3. Run the commands to check the integrity of the /etc/passwd and the /etc/group files.

Discuss your findings with the instructor.

Answer:

Use pwck and grpck commands. You may want to modify the /etc/passwd and

/etc/group files to cause pwck and grpck commands to show some output.

4. Add a user called date that executes the date command. What would happen if you tried

to log in using the user name date?

H3064S A.01 Solutions-10

© 1999 Hewlett-Packard Company

Answer:

Entry in /etc/passwd:

date::92:1::/:/usr/bin/date

This could be created with vipw, SAM, or useradd and passwd. The command date is a

valid login user name as indicated in the /etc/passwd file. more the /etc/passwd file

and look at the command field (last entry) for these user names.

5. Use SAM to deactivate one of the new accounts you set up using SAM. Is the account still

listed in /etc/passwd?

Answer:

The entry should still be in /etc/passwd with an encrypted password of *.

4-6. LAB: Customizing User Accounts

1. PART I

Modify the appropriate configuration file so that root will have access to command line editing

at next login.修改适当的配置文件,使root在下次登录时可以使用命令行编辑。

Answer:

# vi .profile

export EDITOR=vi

export HISTFILE=~/.sh_history

export HISTSIZE=50

2. Modify the appropriate configuration file so that the system administrator’s shell prompt

displays the present working directory and user name after the next login.修改适当的配置文件,使下次登录时系统管理员的shell提示符显示当前工作路径和用户名。

Answer:

# vi .profile

export PS1=’$LOGNAME:$PWD #’

3. If your system is running CDE, modify root’s CDE login script to ensure that the system

consults your .profile at next login.如果你的系统运行着ced,则修改rootced登录脚本,使下次登录时系统运行你的.profile文件

Answer:

# vi .dtprofile

DTSOURCEPROFILE=true

4. Over the course of this week, you will run several scripts in the /labs directory. There

should be a program in your /labs directory called xroach. What message do you get when

you run xroach from your home directory by typing: xroach

Solutions-11 H3064S A.01

© 1999 Hewlett-Packard Company

Answer:

This will yield an sh: xroach: not found message.

5. Do whatever is necessary to ensure that you can run xroach and the other executables in

/labs from any directory.

Answer:

# vi .profile

export PATH=$PATH:/labs

6. Log out, then log back in again to see if your changes were successful.

Answer:

1. PART II

New users added to your system may appreciate having access to the same functionality you

configured for root in Part I of this lab. How can you ensure that all new user accounts have

the same custom functionality you configured for root in Part I? Make it so.新添加的用户可能希望具有与第一部分里root相同功能的配置。怎样才能保证所有新添加的用户都具有第一部分为root配置的相同功能的呢?实现他

Answer:

# vi /etc/skel/.profile

export EDITOR=vi

export HISTFILE=~/.sh_history

export HISTSIZE=50

export PS1=’$LOGNAME:$PWD #’

export PATH=$PATH:/labs

2. .profile will be read only if your new users have a modified .dtprofile, too. How can

you ensure that new home directories automatically get a copy of the modified .dtprofile

that you created in Part I? Make it so.

Answer:

cp ~root/.dtprofile /etc/skel

3. Create a new user account using SAM or useradd; then log in as that new user and see if

your customizations worked.

Answer:

# useradd -m mickie

# passwd mickie

H3064S A.01 Solutions-12

© 1999 Hewlett-Packard Company

# login mickie

# exit

4. Do changes to /etc/skel affect already-existing accounts? Try logging in as user24 to

find out. Does user24 have the custom prompt you configured in /etc/skel/.profile?

Answer:

# login user24

# exit

user24 was not affected by the new /etc/skel/.profile. The files in /etc/skel are

copied only to new home directories.

5-5. LAB: HP-UX File System Hierarchy

1. Which of the following directories are dynamic?下面那些目录是动态的?

/etc

/usr共享的操作系统命令,库文档和文档

/sbin启动系统和安装其它文件系统时需要的必要命令

/dev

/tmp

Answer:

/etc系统配置文件,不包含可执行文件  

/dev设备文件

/tmp临时文件

2. Viewing a report on your disk space usage, you note that /usr, /var, and /opt are all

nearing 90% capacity. Which of these directories should you be most concerned about? Why?

查看你的硬盘空间使用报告时,你发现/usr, /var/opt的使用率都接近90%哪一个目录最需要你的注意为什么

Answer:

/var deserves值得 the most attention注意 here because it is a dynamic file system that could grow

quite quickly in case of an error condition以……条件 that creates entries复数 in the system log files. /usr

and /opt应用程序 are static file systems that are less likely to cause problems.

3. Match the directory with its contents:将目录和它的内容对应

1. /usr/share/man A. kernel, boot loader

2. /stand B. system configuration files

Solutions-13 H3064S A.01

© 1999 Hewlett-Packard Company

3. /var/adm C. shareable operating system commands

4. /etc D. man pages

5. /usr E. application directories

6. /opt F. common admin files and logs

Answer:

1. /usr/share/man D. man pages

2. /stand A. kernel, boot loader

3. /var/adm F. common admin files and logs

4. /etc B. system configuration files

5. /usr C. shareable operating system commands

6. /opt E. application directories

4. Where would you expect to find the cp and rm OS user executables? See if you are correct.

你希望在那里找到操作系统用户可执行文件cp,rm?找到他们

Answer:

Both are in /usr/bin, along with all the other user executables.

5. Where would you expect to find the sam, useradd, and userdel executables? See if you

are correct.从那里能找到可执行文件sam,useradd,userdel?找到他们

Answer:

All three are in /usr/sbin along with many other administrative utilities.

6. The pre_init_rc utility executes in the early stages of the system start-up procedure to

check for file system corruption. Where would you expect to find this executable? See if you are

correct. pre_init_rc使用工具在系统启动过程的前期检查文件系统的错误,找到这个可执行文件。

Answer:

pre_init_rc is in the /sbin directory, along with other files used during the boot process.

7. There is a system log file that maintains a record of system shutdowns. Where would you

expect to find the shutdown log file? See if you are correct.有一个系统日志文件维护系统关闭记录,你在哪能查找到关机日志文件?

Answer:

The full pathname is /var/adm/shutdownlog.

Most OS log files are kept in /var/adm.

8. In which directory would you expect to find the "hosts" configuration file, which contains

network hostnames and addresses? See if you are correct.

你在那个目录能查找到包含网络主机名称和地址的hosts配置文件?找到他

Answer:

The pathname for the hosts file is /etc/hosts.

9. Though many utilities and daemons maintain independent log files, many daemons and

services write their errors and other messages to a log file called syslog.log. See if you can

H3064S A.01 Solutions-14

© 1999 Hewlett-Packard Company

find the path for this file, then check to see if any messages have been written to the file in the

last day.虽然许多程序和进程有独立的日志文件,但很多进程和服务将他们的错误信息与其它信息记录到syslog.log中,找到这个文件的路径并查看昨天是否有信息写到这个文件。

Answer:

# more /var/adm/syslog/syslog.log

10. Use the whereis command to search for the xclock executable. The executable is actually

under /usr/bin/X11/xclock. Did whereis find this executable? Explain.

whereis命令查找xclock执行文件,这个文件实际在/usr/bin/x11/xclock中,whereis找到这个文件了么?为什么

Answer:

# whereis xclock

whereis finds the man page, but probably doesn’t find the executable. Remember that

whereis doesn’t search all directories: it searches only selected directories where

executables are normally found. whereis does not search /usr/bin/X11, so it didn’t find

xclock.

11. Find all of the files (if any) under /home that are owned by root.找到/home 目录下所有属于root的文件。

Answer:

find /home -user root

12. (Optional) Find all the files under /tmp that haven’t been accessed within the last day.找到/tmp目录下所有在最后1天没有被访问过的文件

Answer:

find /tmp -atime +1

13. (Optional) Find all the files on your system that are greater than 10000 bytes in size. If

you needed to make some disk space available on your system, would it be safe to simply

remove these large files?找到系统上所有大于10000字节的文件。如果你想让一些系统的硬盘空间可用,简单的删除这些大文件会安全么?

Answer:

find / -size+10000c

6-8. LAB: Viewing the Configuration with ioscan

1. Which hardware path on this machine might be used for a serial (RS-232) modem?这台机器上那个硬件路径是被串口(RS-232)modem使用的?

Answer:

8/16/4 or 8/20/2 are the only serial RS-232 ports on this system.

2. Which hardware path on this machine might be used for a parallel printer?那个硬件路径是给并行打印机的?

Solutions-15 H3064S A.01

© 1999 Hewlett-Packard Company

Answer:

8/16/0 is the parallel interface card’s address.

3. How many LAN interfaces does this machine have? What are their hardware paths?这台机器上有多少局域网接口?它们的硬件路径是什么?

Answer:

There are two LAN interfaces. One is at 8/16/6. The other is on the EISA bus at 8/20/5/1.

4. How many SCSI interfaces are available on this system? How many Fast/Wide SCSI

interfaces are available?这台主机上有多少可用的SCSI接口?有多少可用的FAST/WIDE SCSI接口?

Answer:

There is one single-ended SCSI interface at 8/16/5, and one Fast/Wide SCSI interface at 8/4.

5. How many disks are connected to the system shown in the ioscan above?有多少个硬盘与系统连接?

Answer:

There appear to be three "disk" class devices. Note in the description column, however,

that one of the "disk" class devices is actually a CD-ROM.

6. What are the hardware addresses of the SEAGATE disks? What are the SCSI addresses of

the SEAGATE disks?   SEAGATE硬盘的硬件地址是什么?SEAGATE硬盘的SCSI地址是多少

Answer:

hardware paths: 8/4.5.0 (SCSI target 5)

8/4.6.0 (SCSI target 6)

7. If you were to add another Fast/Wide SCSI disk to this system, what SCSI target address

could you use for the new disk?如果要添加另一个Fast/wide SCSI硬盘,可以为新硬盘使用那个SCSI地址?

Answer:

0-15 are valid addresses for Fast/Wide SCSI devices. However, addresses 5-7 are already

in use. Thus, the new device could be assigned any address in the range 0-4 or 8-15.

8. If you were to attach a new FW-SCSI disk at target address 4, what would be the resulting

hardware path for the newly attached disk?如果要在目标地址4安装一个新的FW-SCSI硬盘,新安庄的硬盘的硬件路径是什么?

Answer:

8/4.4.0 would be the hardware path.

9. Is the tape drive on this system connected to the Fast/Wide SCSI chain, or the

single-ended SCSI chain? What is the hardware address of the tape drive? What is the SCSI

address of the tape drive?系统上的磁盘驱动器连接到FAST/WIDE SCSI链还是single-ended SCSI链?磁带驱动器的硬件地址是什么?磁带驱动器的SCSI地址是什么?

Answer:

The tape on the single-ended SCSI chain, off the interface card at 8/16/5.

H3064S A.01 Solutions-16

© 1999 Hewlett-Packard Company

Hardware address: 8/16/5.0.0 (SCSI target 0)

7-15. LAB: Device Files

1. PART I

Use ioscan to find the names of the device files for all of your disk class devices.ioscan查找所有硬盘类设备文件

Answer:

# ioscan -fnC disk

2. Use ioscan to find the names of the device files for your system’s LAN card(s).ioscan查找系统上局域网卡的设备文件名。

Answer:

# ioscan -fnC lan

3. You should have a LAN card device file named /dev/lan0. Execute the command that

lists the characteristics of this device file. What kernel driver is associated with this device

file? What hardware path is associated with this device file?应有一个局域网卡设备文件为/dev/lan0,执行命令列出这个设备文件的特性。那个内核驱动与这个设备文件相关?那个硬件路径与这个设备文件相关?

Answer:

# lssf /dev/lan0

4. How does lssf know which kernel driver is associated with each device file?                             lssf怎样知道内核驱动与设备文件的对应相关

Answer:

lssf determines确定 the driver associated合作 with a device file by examining the device’s major

number. lssf determines the hardware path of the device file by examining the device

file’s minor number.

5. Choose one of the disk device files in your /dev/dsk directory. Execute the command that

lists the characteristics of this device file. What kernel driver is associated with this device

file? What is the hardware path of the disk associated with this device file?

/dev/dsk目录下选择一个硬盘设备文件,执行命令列出这个设备文件相关的特性。那个内核驱动与这个设备文件相关?那个硬件路径与这个设备文件相关?

Answer:

# lssf /dev/dsk/c0t6d0 # the disk device filename will vary.

6. (Optional) – If you have a tape drive on your system, run lssf /dev/rmt/*. Which device

file(s) access your tape drive with the no-rewind feature?如果系统上有一个磁带驱动器,执行lssf  /dev/rmt/*.那个设备文件用‘不回卷’方式访问你的磁带驱动器?

Answer:

# lssf /dev/rmt/*

NOTE: File name typically ends in n or nb

Solutions-17 H3064S A.01

© 1999 Hewlett-Packard Company

1. PART II

Go to SAM --> Peripheral Devices --> Terminals and Modems. Are there any

modems or terminals currently?

Answer:

2. First, configure a modem on your first available serial port.

1. Choose Actions –> Add Modem.

2. Choose a serial port/MUX interface hardware path.

3. Click Port Number to choose an available MUX port (Choose 0 on workstations).

4. Choose any baud rate (Doesn’t really matter since we don’t have a real modem.).

5. Choose to support both incoming and outgoing calls.

6. Click OK.

What device files does SAM create for you?

Answer:

SAM should have created three device files:

/dev/cul0p0

/dev/ttyd0p0

/dev/cua0p0

3. Now configure a hard-wired terminal on another available serial port.

1. Choose Actions –> Add Terminal.

2. Choose a serial port/MUX hardware path.

3. Click Port Number to choose an available MUX port.

4. Choose "H" as the baud rate.

5. Click OK.

What device files does SAM create for you?

Answer:

SAM should create a single device file for you: /dev/tty1p0 (The actual device filename

will vary, depending on the hardware path and port number you chose for your terminal.)

4. (Optional) If you have a tape drive on your machine, use SAM to create a non-standard

device file for it. Specify a DDS1 density, no compression, Berkeley style semantics. Let the

other options default.

This DDS1 device file may be useful if you create tapes that may need to be read on older tape

drives that don’t support the high density format used by "BEST" device files. What device file

does SAM create?

H3064S A.01 Solutions-18

© 1999 Hewlett-Packard Company

Answer:

Go to SAM –> Peripheral Devices –> Tape Drives.

Select a tape drive.

Choose Actions –> Create Device Files –> Create Custom Device File.

Click on the Density button and select DDS1 .

Take the defaults for the rest of the dialog box.

SAM should create a device file called /dev/rmt/c0t0d0DDS1b.

Click OK.

1. PART III

Remove the block device file for one of your disks.

Answer:

# rm /dev/dsk/c0t5d0

2. Do an ioscan -funC disk to ensure the device file is gone.

Answer:

3. Recreate the device file with insf -evC disk. The e option ensures that the device file is

recreated even if the disk already exists in /etc/ioconfig. v stands for verbose, and C disk

just recreates disk class devices.

Answer:

# insf -evC disk

4. Check to see that the device file was recreated.

Answer:

# ioscan -funC disk

ioscan should show that the /dev/dsk device file for your disk is back.

7-16. REVIEW: Check Your Understanding

1. What is a device file?

Solutions-19 H3064S A.01

© 1999 Hewlett-Packard Company

Answer:

A device file is used to associate a physical device with a logical file name.

2. What is the difference between a block and a character device file?

Answer:

The smallest unit that is exchanged during an I/O operation with a block device is a block

(defined by f_blksize as returned by ustat(2)). The smallest unit that is exchanged

during an I/O operation with a character device is a byte (eight bits).

3. Why do you need both block and character device files for disks?

Answer:

Because some commands like mount expect a block device and other commands like newfs

expect a character device.

4. What are major and minor numbers?

Answer:

Major numbers describe the kind of device and the device driver. Minor numbers describe

the location of the device and device dependent specialties.

5. What do the insf and mksf commands do?

Answer:

They create device files based on the information in /etc/ioconfig.

6. What is the difference between the ll and the lssf commands related to device files?

Answer:

ll lists major and minor numbers in their "encrypted" form, whereas lssf decrypts them

into a readable form.

7. What does the lsdev command do?

Answer:

The lsdev command gives a listing of all device drivers and the corresponding block and

character major numbers.

阅读(1617) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~