当我在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. selenium--单选下拉列表

    下拉选择 from selenium import webdriver from time import sleep driver = webdriver.Chrome() driver.get(&q ...

  2. Codeforces Round 561(Div 2)题解

    这是一场失败的比赛. 前三题应该是随便搞的. D有点想法,一直死磕D,一直WA.(赛后发现少减了个1……) 看E那么多人过了,猜了个结论交了真过了. 感觉这次升的不光彩……还是等GR3掉了洗掉这次把, ...

  3. 在centos系统的/etc/hosts添加了 当前主机的 ‘ NAT分配的IP controller’,RabbitMQ添加用户报错。

    在centos系统的/etc/hosts添加了 当前主机的 ' NAT分配的IP controller',RabbitMQ添加用户报错. rabbitMq添加用户 报错信息如下 [root@contr ...

  4. npm和yarn设置镜像源

    npm 设置为淘宝源 npm config set registry https://registry.npm.taobao.org 使用nrm管理 nrm: npm registry manage ...

  5. hread.interrupt()到底意味着什么

    首先,一个线程不应该由其他线程来强制中断或停止,而是应该由线程自己自行停止. 所以,Thread.stop, Thread.suspend, Thread.resume 都已经被废弃了.而 Threa ...

  6. FLASK-SQLALCHEMY如何使用or和and条件进行组合查询

    FLASK-SQLALCHEMY如何使用or和and条件进行组合查询 http://www.cherishlau.site/2018/03/29/flask-sqlalchemy-use-or-and ...

  7. [转帖]iostat 命令详解

    iostat 命令详解 https://www.jianshu.com/p/5fed8be1b6e8 概述 iostat 主要用于输出磁盘IO 和 CPU的统计信息. iostat属于sysstat软 ...

  8. BFS --- 模板题

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 36079   Accepted: 11123 ...

  9. memcpy() 实现循环缓冲区数据的读写

    使用memcpy()函数做循环缓冲区的读写 首先对mencpy函数做个简单的介绍 下面是 memcpy() 函数的声明 void *memcpy(void *str1, const void *str ...

  10. Go语言【项目】 websocket消息服务

    websocket消息服务 目的:搭建websocket服务,用浏览器与服务进行消息交互(写的第一个Go程序) 代码目录结构: 前端html页面: <!DOCTYPE html> < ...