现在我已经顺利地建立了一个用户,我将离开超级用户账号。让我们以新用户身份登录,看一下他们有些什么东东并描述一下这里的内容:
login: dlavigne
Password:
pwd
/usr/home/dlavigne
ls -la
total 12
drwxr-xr-x 2 dlavigne dlavigne 512 Dec 30 11:21 ./
drwxr-xr-x 4 root wheel 512 Dec 30 10:44 ../
-rw-r--r-- 1 dlavigne dlavigne 628 Dec 30 10:44 .cshrc
-rw-r--r-- 1 dlavigne dlavigne 299 Dec 30 10:44 .login
-rw-r--r-- 1 dlavigne dlavigne 160 Dec 30 10:44 .login_conf
-rw------- 1 dlavigne dlavigne 371 Dec 30 10:44 .mail_aliases
-rw-r--r-- 1 dlavigne dlavigne 331 Dec 30 10:44 .mailrc
-rw-r--r-- 1 dlavigne dlavigne 722 Dec 30 10:44 .profile
-rw------- 1 dlavigne dlavigne 276 Dec 30 10:44 .rhosts
-rw-r--r-- 1 dlavigne dlavigne 852 Dec 30 10:44 .shrc
你可以看到为用户建立了一个宿主目录,里面包含很多以点起首的文件。记得我们使用adduser工具时提到的点文件目录吗?让我们现在来看一下:
ls -l /usr/share/skel
total 10
drwxr-xr-x 2 root wheel 512 Dec 8 11:53 ./
drwxr-xr-x 26 root wheel 512 Nov 20 08:11 ../
-rw-r--r-- 1 root wheel 628 Nov 20 07:01 dot.cshrc
-rw-r--r-- 1 root wheel 299 Nov 20 07:01 dot.login
-rw-r--r-- 1 root wheel 160 Nov 20 07:01 dot.login_conf
-rw------- 1 root wheel 371 Nov 20 07:01 dot.mail_aliases
-rw-r--r-- 1 root wheel 331 Nov 20 07:01 dot.mailrc
-rw-r--r-- 1 root wheel 722 Nov 20 07:01 dot.profile
-rw------- 1 root wheel 276 Nov 20 07:01 dot.rhosts
-rw-r--r-- 1 root wheel 852 Nov 20 07:01 dot.shrc
可以看到在我们新用户的宿主目录建立的八个文件都是从这个目录中拷贝的模板文件。另外也可以看到只有超级用户才可以编辑skel目录里的文件。例如,如果你希望所有用户都得到定制过的命令解释器提示符,那么超级用户可以修改usr/share/skel/dot.cshrc文件,此文件会在建立账号时拷贝到所有用户的宿主目录中。还有,超级用户也可以在该目录中放入他希望用户得到的任何其它点文件;例如你可以为用户建立定制好的.xinitrc文件。
现在让我们看一下adduser工具建立的/etc/adduser.message文件:
more /etc/adduser.message
#
# Message file for adduser(8)
# comment: "#"
# default variables: $name, $fullname, $password
# other variables: see /etc/adduser.conf after
# line "## DO NOT DELETE THIS LINE!"
#
$fullname,
your account "$name" was created.
Have fun!
See also chpass(1), finger(1), passwd(1)
让我们把它和新用户收到的信息比较一下;我使用mail命令该用户的邮件信息:
login: dlavigne
Password:
You have mail.
mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/dlavigne": 1 message 1 new
>N 1 genisis Sat Dec 30 12:24 20/540 "Welcome"
& 1
Message 1:
From genisis Sat Dec 30 12:24:19 2000
Date: Sat, 30 Dec 2000 12:24:19 -0500 (EST)
From: User Genisis
To: dlavigne
Subject: Welcome
Dru Lavigne,
your account "dlavigne" was created.
Have fun!
See also chpass(1), finger(1), passwd(1)
& ^D Saved 1 message in mbox
> ^D exit
你可以看到我在成为超级用户以便使用adduser命令这前是以用户“genisis”登录的。我的新用户收到的信息就是adduser.message中包含的内容,而插入的$fullname和$name变量都以实际的值作了替换。
当建立了账号时,我们会得到以下的选项:
Add anything to default message (y/n) [n]:
如果我要建立其它账号并打入y,我会得到以下提示:
Use "." or ^D alone on a file to finish your
message
我打入的内容都会被加入到缺省的信息中,然后发给该特定的用户;但是,这不会覆盖我原先创建的/etc/addus er.message文件。让我们来试一下这样做;我将添加一个称为“test”的账号,显示我们关心的输出并“剪掉”其余的:
adduser
<剪掉>
Add anything to default message (y/n) [n]: y
Use "." or ^D alone on a line to finish your message.
Don't forget that every Friday is pizza day!
.
Send message (y/n) [y]: y
现在让我们看一下用户test的邮件信息是什么样的:
login: test
Password:
You have mail.
mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/test": 1 message 1 new
>N 1 genisis Sat Dec 30 12:47 22/567 "Welcome"
& 1
Message 1:
From genisis Sat Dec 30 12:47:07 2000
Date: Sat, 30 Dec 2000 12:47:07 -0500 (EST)
From: User Genisis
To: test
Subject: Welcome
test,
your account "test" was created.
Have fun!
See also chpass(1), finger(1), passwd(1)
Don't forget that every Friday is pizza day!
再看一下新信息是否被加到了模板文件:
more /etc/adduser.message
#
# Message file for adduser(8)
# comment: "#"
# default variables: $name, $fullname, $password
# other variables: see /etc/adduser.conf after
# line "## DO NOT DELETE THIS LINE!"
#
$fullname,
your account "$name" was created.
Have fun!
See also chpass(1), finger(1), passwd(1)
看来只有该用户收到了附加的信息,这正如我们所期望的。在离开adduser.message文件之前我还想做更多的例子。我想让用户在他们的欢迎邮件中收到下面这条附加信息:
If you have any problems, contact the administrator at
admin@thiscompany.com 试一下你自己建立一个账号并把这行加到他们的信息中;你会看到当你以该用户登录时,附加行没有出现在邮件信息中。但是如果你把这行改成:
If you have any problems, contact the administrator at
admin\@thiscompany.com
那么用户就会收到附加信息了。注意,我们必须用\符号避开@符号,以便正确解释。
最后,让我们看一下刚才建立的adduser.conf文件:
more /etc/adduser.conf
# /etc/adduser.conf - automatic generated by adduser(8)
#
# Note: adduser read *and* write this file
# You may change values, but don't add new things before the
# line "## DO NOT DELETE THIS LINE!"
# use password for new users
# defaultpasswd = yes | no
defaultpasswd = yes
# copy dotfiles from this dir ("/usr/share/skel" or "no")
dotdir = "/usr/share/skel"
# send this file to new user
# ("/etc/adduser.message" or "no")
send_message = "/etc/adduser.message"
# config file for adduser ("/etc/adduser.conf")
config = "/etc/adduser.conf"
# logfile ("/var/log/adduser" or "no")
logfile = "/var/log/adduser"
# default HOME directory ("/home")
home = "/home"
# List of directories where shells located
# path = ('/bin', '/usr/bin', '/usr/local/bin')
path = ('/bin', '/usr/bin', '/usr/local/bin')
# common shell list, first element has higher priority
# shellpref = ('bash', 'tcsh', 'ksh', 'csh', 'sh')
shellpref = ('csh', 'sh', 'bash', 'tcsh', 'ksh', 'no', 'date')
# defaultshell if not empty ("bash")
defaultshell = "tcsh"
# defaultgroup ('USER' for same as
# username or any other valid group)
defaultgroup = USER
# defaultclass if not empty
defaultclass = ""
# new users get this uid (1000)
uid_start = "1000"
## DO NOT DELETE THIS LINE!
## your own variables, see /etc/adduser.message
## end
你可以看到这是个简单的文件,它包含了对adduser工具提示问题的回答。你看到的新信息只是该文件含有addus er记录文件的存放位置。如果看一下这个记录文件,会看到建立账号时的记录:
more /var/log/adduser
2000/12/30 12:24:18 dlavigne:*:1000:1000(dlavigne):Dru Lavigne
2000/12/30 12:47:06 test:*:1001:1001(test):test