【问题标题】:sudo -l for a different as rootsudo -l 作为 root 的不同
【发布时间】:2016-06-16 21:24:55
【问题描述】:

大家好,我正在尝试列出用户以 root 身份访问的所有 sudo 命令,显然我们可以在 sudoers 文件中看到,但如果有很多用户/命令别名,就会变得困难

我正在尝试以 root 身份为不同的用户执行 sudo -l

我尝试过使用 -u 选项

sudo -u testuser -l 

抛出命令使用消息

sudo -u testuser sudo -l

提示输入 testuser 的密码(我不想要密码提示,因为我以 root 身份进行操作)

su - testuser -c 'sudo -l' 

给我以下错误

sudo: no tty present and no askpass program specified

请告诉我该怎么做

【问题讨论】:

    标签: command sudo sudoers


    【解决方案1】:

    根据man sudo

     -U user, --other-user=user
                 Used in conjunction with the -l option to list the privileges
                 for user instead of for the invoking user.  The security pol-
                 icy may restrict listing other users' privileges.  The
                 sudoers policy only allows root or a user with the ALL privi-
                 lege on the current host to use this option.
    

    你使用的是-u,这是完全不同的东西:

     -u user, --user=user
                 Run the command as a user other than the default target user
                 (usually root ). The user may be either a user name or a
                 numeric user ID (UID) prefixed with the '#' character etc...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 2013-09-07
      • 1970-01-01
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多