其他分享
首页 > 其他分享> > 不使用 useradd 创建用户

不使用 useradd 创建用户

作者:互联网

第一步:

在 /etc/passwd=文件内追加一条
echo st:x:1001:1001::/home/st:/bin/bash >> /etc/passwd



                            """
                不能登录此时只能查看id,id组群是不属于root                    的属主,属组都是root

                                """

第二步:

/etc/skel 这个目录是linux在创建用户时的一个模板目录, 创建一个用户后,都会将该目录下的所有内容复制到用户的家目录里,那么我们把这个目录复制一份到/home下

cp -a /etc/home/st


此时st就可以登录了,但你会发现还是有问题的,因为如果你用ls -l  查看st目录


drwxr-x 3 root root 4096 10-21 05:27 st

第三步:

/etc/passwd里面输入的uid为504, gid也是504, 那就要创建一个群组


echo stu4:x:1001: >>/etc/group

"""然后再把/home/st 的所有者和所有组修改下"""

chown -R st:st /root/home/stu4    #-R  将目录下的所有文件改变

第四步:添加密码

#passwd st
Changqing password for user st.
New password:
Retype new password:
passwd: all authentication tokens updata successful

 

标签:passwd,创建,用户,st,etc,useradd,home,root,目录
来源: https://www.cnblogs.com/fkzxps/p/15689382.html