当我在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. table开发中遇到的问题

    table元素是一个很常用的元素.但是在开发中,我也遇到了一些值得记录下来的问题及解决方案: 1.td内容溢出时,隐藏内容并且以省略号提示 .hide-content{ /* 不换行 */ white ...

  2. 认识随机函数rand()和srand(unsigned int )

    rand函数 int rand( void ); 函数名:   rand 功   能:   随机数发生器 用   法:   int rand(void); 所在头文件: stdlib.h 函数说明 : ...

  3. Oracle_PLSQL导出导入dmp文件

    地址:F:\app\duling\product\11.2.0\dbhome_1\BIN\imp.exe ----------------------------------------------- ...

  4. vue、element-ui开发技巧

    1.vue下input文本框获得光标 html: <el-input size="mini" clearable v-model.trim="addOrEditDa ...

  5. 【RS】AutoRec: Autoencoders Meet Collaborative Filtering - AutoRec:当自编码器遇上协同过滤

    [论文标题]AutoRec: Autoencoders Meet Collaborative Filtering (WWW'15) [论文作者]Suvash Sedhain †∗ , Aditya K ...

  6. 5 系统的软中断CPU升高,一般处理办法?

    还是需要多动手,一个一个问题个被get!

  7. Python3+syslog使用及相关说明

    一.说明 1.1 背景说明 syslog这个东西,最早接触是在Z公司做基线安全加固的时候有启用远程日志服务器一项,然后当时还写整理了一篇“rsyslog+loganalyzer远程日志系统搭建教程(C ...

  8. 图论 --- BFS + MST

    Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7844   Accepted: 2623 Descrip ...

  9. AtCoder-arc059 (题解)

    A - いっしょ / Be Together (结论/暴力) 题目链接 题目大意: 有 \(n\) 个数字,要将它们变成相等,对每一个数字最多操作一次,如将 \(a \to b\) 的代价为 \((a ...

  10. C++ 结构体、模板、类、重载初使用

    目的:需要几个缓存用的数组900*750 首先定义一个模板<参数数据类型,参数1,参数2> 定义一个class类 名字自己取ap_uint0 下面是公用的数组模板[lrow][lcol] ...