修改Linux用户名,需要被修改的用户名的用户不处于登录状态

[root@hadoop001 ~]# usermod -l hadoop002 -d /home/hadoop002 -m hadoop001
usermod: user hadoop001 is currently logged in

克隆VMware虚拟机hadoop001,克隆后新虚拟机名称为hadoop002,对新虚拟机修改用户名和密码。将克隆过后的新虚拟机hadoop001用户名修改为hadoop002;密码进行修改。

切换到root用户

id命令用来显示用户的用户id,组id,所属组等

1.修改用户名

[root@hadoop001 ~]# id hadoop001
uid=500(hadoop001) gid=500(hadoop001) groups=500(hadoop001)
[root@hadoop001 ~]# usermod -l hadoop002 -d /home/hadoop002 -m hadoop001
[root@hadoop001 ~]# id hadoop001
id: hadoop001: No such user
[root@hadoop001 ~]# id hadoop002
uid=500(hadoop002) gid=500(hadoop001) groups=500(hadoop001)
[root@hadoop001 ~]# groupmod -n hadoop002 hadoop001
[root@hadoop001 ~]# id hadoop002
uid=500(hadoop002) gid=500(hadoop002) groups=500(hadoop002)

也可以新添加用户,删除老用户名

[root@hadoop001 ~]# useradd hadoop002
[root@hadoop001 ~]# userdel -r hadoop001

配置文件中保存的用户信息

配置文件用处
/etc/passwd保存用户信息
/etc/shadow保存用户密码(加密)
/etc/group保存组信息

2.修改密码

[root@hadoop001 ~]# passwd hadoop002
Changing password for user hadoop002.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

本文参考:
http://blog.csdn.net/yiranant/article/details/46124145

Logo

更多推荐