Installing 4.3 BSD Quasijarus on SIMH
目标:要在4.3BSD中新增加用户dmr,指定目录/home/dmr,uid为10 gid=31(guest组,系统已建立)
4.3BSD还没有adduser或useradd
直接修改/etc/passwd增加dmr条目,不行:
4.3 BSD UNIX (myname.my.domain) (console)
login: root
Last login: Thu Jul 15 17:00:20 on console
Jul 15 17:05:17 myname login: ROOT LOGIN console
4.3 BSD Quasijarus UNIX #3: Sat Feb 14 20:31:03 PST 2004
Welcome to UNIX!
erase ^?, kill ^U, intr ^C
# cat /etc/group
wheel:*:0:root
daemon:*:1:daemon
kmem:*:2:root
sys:*:3:root
tty:*:4:root
operator:*:5:root
bin:*:10:root
guest:*:31:root
ingres:*:74:ingres
nobody:*:32767:nobody
# cat /etc/passwd
root::0:0:System Manager:/:/bin/sh
daemon:*:1:31:System &:/:
operator:*:2:28:System &:/:/bin/sh
bin:*:3:10:System Binaries:/:
games:*:7:2:Games pseudo-user:/usr/games:
dmr:*:10:31:Dennis Ritchie:/home/dmr:
uucp:*:66:1:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/lib/uucp/uucico
nobody:*:32767:32767:Unprivileged user:/nonexistent:/dev/null
# passwd dmr
passwd: dmr: unknown user.
# ls /etc/passwd*
/etc/passwd /etc/passwd.dir /etc/passwd.pag
需要修改/etc/passwd.pag,不能直接修改,需要用到mkpasswd命令生成passwd.dir和passwd.pag文件
mkdir /home/dmr (建立dmr用户主目录)
cd
cp /etc/passwd . (在root的主目录下操作,而不是在/etc下,以免误操作)
echo "dmr:*:10:31:Dennis Ritchie:/home/dmr:" >> passwd
mkpasswd passwd (生成passwd passwd.dir passwd.pag)
mv passwd* /etc/. (这时候dmr被创建了)
passwd dmr (修改dmr密码)
chown dmr /home/dmr
# cp .login /home/dmr
# cp .profile /home/dmr
# cp .cshrc /home/dmr
# cp .cshrc /home/dmr
# cd /home/dmr
# chown dmr .cshrc
# chown dmr .login
# chown dmr .profile
# login
login: dmr
Password:
测试代码:
$ cat > myid.c
#include <stdio.h>
#include <sys/types.h>
main()
{
printf("uid is %d,gid is %d\n", getuid(),getgid());
}
$ cc myid.c
$ a.out
uid is 10,gid is 31
$