增加用户:
推荐使用 sudo adduser xxx
然后会提示输入密码,以及联系方式等信息,在此略过。
赋予root权限:
sudo vi /etc/sudoers
在# User privilege specification
下方增加xxx ALL=(ALL:ALL) ALL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL xxx ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d |
保存之后即可。
本文最后更新于2020年11月10日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
有一事请教,我是业余玩家。
sudo vi /etc/sudoers这个命令须在root用户下执行,弹出页面为只读。
所以我执行的是sudo nano /etc/sudoers,弹出的页面就能修改了。
我不太懂是怎么回事。请指教,是不是由于我用的镜像版本不同所以才是只读?
奥,对了,我是用的这个地址:
https://yadi.sk/d/_rQgn_FosYuW0g/20.10/20201014
这个镜像:
Armbian_20.10_Arm-64_focal_current_5.9.0_desktop.img
@weiding920 是这样的,vi命令虽然显示只读,但是修改之后仍然是可以保存的。只需要使用wq!既可以保存。这是正常现象,因为sudoers这个文件太重要了,所以即使是sudo下运行,仍然会要求强制保存。