Linux --赋予普通用户root 权限

资源来源:

https://www.linuxidc.com/Linux/2012-07/64530.htm

Linux的普通用户在安装一些东西的时候或者执行命令的时候,终端始终会提示权限不够,我们会将这个普通用户赋予root权限,但是,和root还是有区别的,因为只能执行root规定好的一些操作命令。

1、添加用户,首先用adduser命令添加一个普通用户,命令如下:

#adduser claire   //添加一个名为claire的用户

#passwd claire   //change the password

changing password for user claire

New unix password :  //input new password

Retype new unix password:  //input the new password again

password:all authentication tokens updated successfully.

2.赋予root 权限

方法一:

change /etc/sudoers file ,找到%wheel 一行,把前面的注释(#)去掉

##Allow people in group wheel to run all commands

扫描二维码关注公众号,回复: 6559503 查看本文章

%wheel ALL=(ALL)   ALL

然后修改用户,使其属于root组(wheel),命令如下:

#usermod -g root claire

修改完毕后,现在可以用claire 账号登陆,然后用sudo su -,即可获得root权限进行操作。

方法二:

修改/etc/sudoers 文件,找到root一行,在root下面添加一行,如下所示:

root  ALL=(ALL)  ALL

claire  ALL=(ALL)  ALL

修改完毕后,可以用claire账号登陆,然后用sudo su - ,即可获得root权限。

猜你喜欢

转载自www.cnblogs.com/clairedandan/p/11061128.html