当我在postgres用户下去执行sudo vim demo.sql需要用管理员权限运行时,并且输入本用户的密码,但是输入之后提示如下:

postgers is not in the sudoers file. This incident will be reported

  翻译一下:postgres 不在sudoers文件中。将报告此事件。

  这时候我们可以根据提示去找到这个 sudoers file 。也就是就是在/etc/sudoers文件里给该用户添加权限。

 解决方法如下:

  1.切换到root用户下

  2./etc/sudoers文件默认是只读的,对root来说也是,因此需先添加sudoers文件的写权限,命令是:

chmod u+w /etc/sudoers

  3.然后就可以编辑sudoers文件

vim /etc/sudoers

  找到这行 root ALL=(ALL) ALL  ,在他下面添加 xxx ALL=(ALL) ALL  (这里的xxx是你的用户名).

root ALL=(ALL) ALL
progres ALL=(ALL) ALL

  PS : 这里说下你可以sudoers添加下面四行中任意一条。

 youuser   ALL=(ALL)  ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL

  解释如下:

  • 第一行:允许用户youuser执行sudo命令(需要输入密码).
  • 第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
  • 第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
  • 第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.

  4.撤销sudoers文件写权限,命令:(通常/etc下文件均是不可写的文件,这时可以:)

chmod u-w /etc/sudoers

  然后再去执行:

  sudo vim demo.sql,输入密码即可。

  over~~~,参考,感谢:https://www.linuxidc.com/Linux/2016-07/133066.htm,~~~

  

  

关于Ubuntu下is not in the sudoers file解决方法的更多相关文章

  1. Linux下is not in the sudoers file解决方法

    最近在学习linux,在某个用户(xxx)下使用sudo的时候,提示以下错误:xxx is not in the sudoers file. This incident will be reporte ...

  2. [转]Linux下is not in the sudoers file解决方法

    来源: http://jingyan.baidu.com/article/2a1383284bb3e8074a134f2d.html 当我们使用sudo命令切换用户的时候可能会遇到提示以下错误:xxx ...

  3. Ubuntu下is not in the sudoers file 问题解决

    在Ubuntu12.04 下,使用sudo apt-get install XXX 时,突然跳出 username is not in the sudoers file的问题 然后我一查此userna ...

  4. ubuntu下Qt cannot find -lGL错误的解决方法 (转载)

    在ubuntu下使用Qt 编译时候遇上了cannot find -lGL错误,使用命令 sudo apt-get install libqt4-dev或者sudo apt-get install li ...

  5. ubuntu下QT输出程序控制台界面难看的解决方法

    这几天在ubuntu下装了QT5,但输出程序界面后,简直无法入目 于是,随便乱找后,终于找到解决方法 打开选项 在终端那行改下就行

  6. win使用telnet到ubuntu下vim显示中文为乱码的解决方法~

    1.几个路径: ubuntu: /etc/default/locale  相当于 centos:/etc/sysconfig/i18n vimrc的路径:① ~/.vimrc    ② /etc/vi ...

  7. is not in the sudoers file解决方法

    用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权 ...

  8. Linux中“is not in the sudoers file”解决方法

    当在终端执行sudo命令时,系统提示"hadoop is not in the sudoers file": 其实就是没有权限进行sudo,解决方法如下(这里假设用户名是cuser ...

  9. [RedHat]“is not in the sudoers file”解决方法

    当在终端执行sudo命令时,系统提示“luckchengis not in the sudoers file”: $ sudo ls Password: luckcheng is not in the ...

随机推荐

  1. 基于web公交查询系统---搭建mvc连接数据库(我的毕业设计,进度继续)

    建立一个spring的项目:我在已经做过的项目基础下做的,所以接口连接数据库挺快. 搭建好的.对应好数据库: 前几天进度已经完成简单的设计: 完成登录,用户管理(修改删除). 继续的数据库的信息获取, ...

  2. CSS 分割线

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. R 语言解压目录下的所有gz文件

    setwd("GSE29431_RAW") # 进入目录 fileNames <- list.files() # 获取目录下的所有文件 sapply(fileNames, g ...

  4. Linux 内核启动信息的打印 --- dev_driver_string函数/dev_name函数

    内核启动时,常会打印出一些信息:开头是 "驱动模块的名字: + 具体的信息" 如:在运行的linux系统设备上,插入鼠标,就会打印出鼠标的相关信息; [ 402.134068] i ...

  5. Golang(二)基本概念

    类型 18个基本类型:bool.string.rune.byte.int.uint.int8.uint.int8.int16.uint16.int32.uint32.int64.uint64.floa ...

  6. how to write your first linux device driver

    how to write your first linux device driver 0. environment-ubuntu 1804 64bit 1. apt-get install linu ...

  7. javascript的立即执行函数

    在javascript中有引入立即执行函数的概念,那么什么是立即执行函数呢?立即执行函数又是怎么写的呢?立即执行函数与普通函数有什么区别呢? 先来看看一般的函数: function a(){ var ...

  8. kafka原理篇

    目录 消息队列分类 点对点 发布/订阅 kafka介绍 kafka架构说明 Topic与Partition的关系 partition复制机制 Consumer与Topic的关系 消息队列分类 点对点 ...

  9. TJOI2018简要题解

    Day1T1数学计算 按照时间轴建一棵线段树即可,复杂度为\(O(m \log m)\) #include <bits/stdc++.h> #define N 100005 #define ...

  10. golang 学习笔记 使用cmd

    package main import ( "bytes" "fmt" "os/exec" ) func main() { cmd0 := ...