資源來源:
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
%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權限。