Centos 添加Root用户

今天,我要描述的是如何在Centos Linux 系统中建立一个和Root账户等权限的用户账户。废话不多说,开始列出必要的操作。
1:首先,我们使用以下命令 进行用户的创建 和 用户密码的初始化。
#adduser testuser//添加一个名为testuser的用户 #passwd testuser //修改密码 Changing password for user testuser. New UNIX password: //在这里输入新密码 Retype new UNIX password: //再次输入新密码 passwd: all authentication tokens updated successfully.
2:然后,我们可以采用下面连续步骤,提高用户权限
Step1:
修改 /etc/sudoers 文件,找到下面一行,把前面的注释(#)去掉
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
然后修改用户,使其属于root组(wheel),命令如下:
usermod -g root testuser
gpasswd -a corerman wheel
Step2:
修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
testuser ALL=(ALL) ALL
Step3:
修改 /etc/passwd 文件,找到如下行,把用户ID修改为 0 ,如下所示:
testuser:x:500:500:testuser:/home/testuser:/bin/bash
修改后如下
testuser:x:0:500:testuser:/home/testuser:/bin/bash
保存,用testuser账户登录后,直接获取的就是root帐号的权限。
虽然,上面的步骤比较繁多,但是兼容性相对较好,操作执行一遍后,直接用新用户登录即可获取Root权限。
浙公网安备 33010602011771号