ubuntuUbuntu Server 12.04 的 AWS 映像上的用户如何在sudo没有配置的情况下对所有命令设置无密码/etc/sudoers?
我在亚马逊上使用 Ubuntu 服务器 12.04。我想添加一个与默认 Ubuntu 用户具有相同行为的新用户。具体来说,我希望sudo这个新用户无密码。
所以我添加了一个新用户并开始编辑/etc/sudoers(当然使用 visudo)。通过阅读该文件,似乎默认ubuntu用户sudo从成为该admin组的成员中获得了无密码。所以我添加了我的新用户。这没有用。然后我尝试将NOPASSWD指令添加到sudoers. 这也不起作用。
无论如何,现在我只是好奇。怎样的ubuntu,如果他们没有在定义用户密码的获得特权/etc/sudoers。允许这样做的机制是什么?
我在 /etc/sudoers 中有一个 NOPASSWD 行(用 编辑visudo)
gatoatigrado ALL=(ALL) NOPASSWD: /bin/set-slow-cpufreq
Run Code Online (Sandbox Code Playgroud)
然而,输出是,
gatoatigrado@coral:~> sudo -n /bin/set-slow-cpufreq
sudo: sorry, a password is required to run sudo
Run Code Online (Sandbox Code Playgroud)
这种命令适用于 OpenSuSE 机器,但不适用于 Ubuntu 11.10。我究竟做错了什么?
注意:我找不到任何相关的系统日志消息,例如通过tail -f /var/log/syslog.
这是/etc/sudoers。
Defaults env_reset
# things I've tried copying from an opensuse machine
Defaults always_set_home
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE"
root ALL=(ALL:ALL) ALL
gatoatigrado ALL=NOPASSWD: /bin/set-slow-cpufreq
%admin ALL=(ALL) …Run Code Online (Sandbox Code Playgroud) 我知道我可以通过su命令成为 root(超级用户),但我必须在输入命令后对其进行授权。有没有一种方法可以成为 root 并在一行中授权(使用密码)
我多次遇到这种情况。
例如,每当我尝试打开一些文件emacs与sudo使用权限:
sudo emacs tet.c &
Ubuntuemacs没有询问我的密码,而是在没有任何emacs窗口或终端上的任何输出(pid 除外)的情况下启动进程,查看图像(如果我不使用“&”,那么它会询问我的密码):
我有两个与此相关的问题:
当我收到“有停止的作业”的错误消息时该怎么办?我如何识别所有这些停止的工作并杀死它们?一旦我清除了终端,我就不会有这些停止进程的 pid。
为什么 Ubuntu/emacs 会这样?为什么它不问我密码?
基本上,我想在add-apt-repository ppa:(whatever)没有“按 Enter 继续”提示的情况下运行。我该怎么做?
本质上,我想在没有用户输入的情况下部署在 shell 脚本中添加存储库。
每当我发出命令时,sudo apt-get install foo它都不会要求输入密码。是因为用户组吗?
如何让它提示输入密码?
编辑:我的 sudoers 文件
apple@Ascension:~$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL …Run Code Online (Sandbox Code Playgroud) 我在 Ubuntu 上的用户帐户是olivier.
当我输入命令时,groups olivier它返回:
olivier : olivier adm cdrom sudo dip plugdev lpadmin sambashare
Run Code Online (Sandbox Code Playgroud)
所以我推断我属于这个sudo组。
我的/etc/sudoers文件中有以下几行:
#Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
Run Code Online (Sandbox Code Playgroud)
如果组的成员sudo可以执行任何命令,sudo当我想以特权执行命令(例如,rm在我不是所有者的文件夹上执行命令)而我与用户一起登录时,为什么我需要使用该命令olivier?
sudo ×5
aws ×1
command-line ×1
emacs ×1
job-control ×1
permissions ×1
ppa ×1
process ×1
scripts ×1
su ×1