普通用户授予root权限

开始用linux的时候会遇到用户权限问题,比如安装软件的时候经常会提示权限不足,下面介绍给普通用户授予root权限。

找到  cd /etc/sudoers可以看到用户的权限是:只有读取的权限(以下操作都是用root用户)

-r--r-----.  1 root root   4029 Jul 22 19:41 sudoers

 vim  进入后提示只有读取的权限。

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now
-- INSERT -- W10: Warning: Changing a readonly file  

给文件 sudoers  授权 读写的权限:chmod 640  /etc/sudoers

-rw-r-----.  1 root root   4029 Jul 22 19:41 sudoers

找到root 用户那行

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
hadoop  ALL=(ALL)       ALL

hadoop 是我新添加的用户,保存

然后再将文件修改成 只有读取的权限 :chmod 440 /etc/sudoers

原文地址:https://www.cnblogs.com/zhanggl/p/3862481.html