解决Linux下无法使用sudo命令问题

问题描述

使用普通用户登录后在终端中执行sudo命令时提示以下错误:

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.

解决方法

一、 切换到root用户

终端中执行 su 命令,然后输入密码,从普通用户切换为根用户

二、为sudoers配置文件添加写权限

sudoers文件位于 /etc 目录下,其为系统配置sudo用户的一个只读配置文件。在root身份下执行 chmod +w /etc/sudoers命令为该文件添加写权限。

三、编辑sudoers配置文件

执行 vi /etc/sudoers 命令对配置文件进行编辑。在文件中先找到

Allows people in group wheel to run all
commands

这段配置,然后在配置下方新起一行添加所需要增加 sudo权限的用户,格式如下

用户名 ALL=(ALL) ALL

猜你喜欢

转载自blog.51cto.com/13589319/2125825