标签:用户密码 home shel 登录shell upd 一个 not useradd fail
添加用户添加用户组
[root@localhost ~]# groupadd -g 30000 shakespeare
[root@localhost ~]# groupadd artists
[root@localhost ~]# tail -n 2 /etc/group
shakespeare:x:30000:
artists:x:30001:
修改用户附加组
[root@localhost ~]# usermod -G shakespeare juliet
[root@localhost ~]# usermod -G shakespeare romeo
[root@localhost ~]# usermod -G shakespeare hamlet
[root@localhost ~]# tail -n 8 /etc/group
juliet:x:6001:
romeo:x:6002:
hamlet:x:6003:
reba:x:6004:
dolly:x:6005:
elvis:x:6006:
shakespeare:x:30000:juliet,romeo,hamlet
artists:x:30001:
[root@localhost ~]# usermod -G artists reba
[root@localhost ~]# usermod -G artists dolly
[root@localhost ~]# usermod -G artists elvis
[root@localhost ~]# tail -n 3 /etc/group
elvis:x:6006:
shakespeare:x:30000:juliet,romeo,hamlet
artists:x:30001:reba,dolly,elvis
同时加入多个附加组
[root@localhost ~]# usermod -G shakespeare,artists romeo
如果用户已有附加组再新加一个附加组,加-a 参数配合-G ,否则之前的组会被替换成新的组
[root@localhost ~]# usermod -G artists romeo -a
[root@localhost ~]# tail -n 2 /etc/group
shakespeare:x:30000:juliet,hamlet,romeo
artists:x:30001:reba,dolly,elvis,romeo
练习二
添加并指定用户组id,添加一个新用户并指定刚才的组为附加组
[root@localhost ~]# groupadd adminuser -g 40000
[root@localhost ~]# useradd natasha -G adminuser
[root@localhost ~]# tail -n 2 /etc/group
adminuser:x:40000:natasha
natasha:x:6007:
创建一个用户并指定其不能登录shell
[root@localhost ~]# useradd sarah -G adminuser
[root@localhost ~]# usermod -s /bin/false
[root@localhost ~]# usermod -s /bin/false sarah
[root@localhost ~]# su - sarah
[root@localhost ~]#
[root@localhost ~]# usermod -s /usr/sbin/nologin sarah
[root@localhost ~]# su - sarah
This account is currently not available.
[root@localhost ~]# tail -1 /etc/passwd
sarah:x:6009:6009::/home/sarah:/usr/sbin/nologin
修改用户密码
[root@localhost ~]# echo gelgunge | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# echo gelgunge | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# echo gelgunge | passwd --stdin sarah
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# su - natasha
[natasha@localhost ~]$ su - harry
Password:
su: Authentication failure
[natasha@localhost ~]$ su - harry
Password:
[harry@localhost ~]$
标签:用户密码 home shel 登录shell upd 一个 not useradd fail
原文地址:https://blog.51cto.com/2738556/2486658