Linux命令之用户账户管理whoami,useradd,passwd,chage,usermod,userdel的使用
发布时间:2024年01月17日
1、查看当前用户账户

2、切换用户为root用户

3、新建用户user1,给用户user1设置密码为password123

4、新建用户user2,UID为510,指定其所属的私有组为group1(group1组的标识符为500),用户的主目录为/home/user2,用户的Shell为/bin/bash,用户的密码为123456,账户永不过期

5、设置用户user2 的密码为空

6、修改用户user2的主目录为/var/user2,把启动Shell修改为/bin/false,并查看修改后的结果

问:注销当前用户,用user2登陆,看能否正常登陆,不能的话,为什么?
答:修改用户user2的主目录和把启动Shell修改为/bin/false后不能正常登录,因为启 ?????动Shell修改为/bin/false后在登录时系统什么也不做,只是返回一个错误状态,然后立即退出,用户将会无法登录,并且不会有任何提示。
7、用passwd禁用用户user1,禁用之后查看/etc/shadow文件


?8、用passwd恢复user1账户

9、用usermod禁用和恢复用户user2

10、删除user1用户,同时删除用户主目录

11、新建用户user3,UID为512,GID为500,用户的shell为/bin/bash,用户的注释性信息为“network 3” 密码为123456.建好用户之后,查看/etc/passwd文件变化


12、设置wangwu的口令最短存活期为5天,最长存活期为7天,口令到期前提前1天警告,口令过期后2天停用账户,并用grep 查看/etc/shadow文件wangwu所在的行。

文章来源:https://blog.csdn.net/Coin_Collecter/article/details/135636355
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:chenni525@qq.com进行投诉反馈,一经查实,立即删除!