1,创建用户并设置密码
# adduser likilone
# passwd likilone
Changing password for user likilone.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2,授予sudo权限
# vim /etc/sudoers
在root ALL=(ALL) ALL 下面添加代码,添加后的代码如下
root ALL=(ALL) ALL
likilone ALL=(ALL) ALL
3,验证sudo
# su likilone
$ sudo ls
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for likilone:
看到如上代码即表示成功设定了
4,其他说明:sudoers只有只读权限,在保存的时候可 输入wq! 进行强制保存
或者在保存之前先修改权限,然后再改回来
修改只读
chmod -v u+w /etc/sudoers
恢复权限
chmod -v u-w /etc/sudoers
爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情