摘录自鸟哥的文档,可以尝试一下不使用useradd的方式添加一个用户:
如下:
- 先建立所需要的群组( vi /etc/group )
- 建立账号的各个属性( vi /etc/passwd )
- 将 passwd 与 shadow 同步化 ( pwconv )
- 建立该账号的密码 ( passwd acount )
- 建立使用者家目录 ( cp -r /etc/skel /home/account )
6. 更改家目录属性 ( chown -R account.group /home/account )
|
建立新的群组 test ,设其 GID 为 520 [root @test /root ]# vi /etc/group ----略 test:x:520:test <==新增群组,且群组的人为 test ,GID 为 520
建立 test 的各个属性 [root @test /root ]# vi /etc/passwd ----略 test:x:520:520:testing account:/home/test:/bin/bash <==建立各个属性
同步化 /etc/passwd 与 /etc/shadow |
|
建立新的群组 test ,设其 GID 为 520 [root @test /root ]# vi /etc/group ----略 test:x:520:test <==新增群组,且群组的人为 test ,GID 为 520
建立 test 的各个属性 [root @test /root ]# vi /etc/passwd ----略 test:x:520:520:testing account:/home/test:/bin/bash <==建立各个属性
同步化 /etc/passwd 与 /etc/shadow [root @test /root ]# pwconv <==将 passwd 的资料转入 /etc/shadow 中!
建立密码 [root @test /root ]# passwd test <==建立使用者 test 密码 Changing password for user test New password: Retype new password: passwd: all authentication tokens updated successfully
建立家目录并转化家目录的拥有者 [root @test /root ]# cp -r /etc/skel /home/test [root @test /root ]# chown -R test:test /home/test |
OK。