我正在尝试为NOPASSWD
属于该sudo
组并具有管理员权限的现有用户添加选项。我在sudoers
文件中添加了这一行:
max ALL=(ALL:ALL) NOPASSWD: ALL
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用sudo
.
需要为我必须做的一些工作下载“traceroute”,我尝试使用“sudo apt-get install”下载软件包。在网上查看后,我看到我可能需要更新软件,但这也不起作用。有任何想法吗?
ubuntu@ubuntu:~$ sudo apt-get install traceroute
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package traceroute is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'traceroute' has no installation candidate
ubuntu@ubuntu:~$ sudo apt-get install update
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package update
Run Code Online (Sandbox Code Playgroud)
PS inetutils-traceroute …
普通用户可以运行这个脚本,但是 root 找不到它。
我有一个简单的脚本,保存在~/bin
. 我更新了.profile
文件以将此文件夹包含在 PATH 中。我可以进入终端,在任何目录中工作,输入脚本的名称,它运行良好。但是如果在那个终端中我切换到 root,则找不到脚本。我假设某处有一些文件需要新的 $PATH 更新,但我不知道是哪一个。
如果我有一个文件
$ touch some_file.txt
Run Code Online (Sandbox Code Playgroud)
我想将它移动到需要sudo
权限的目录
$ cp some_file.txt /usr/local/bin
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
cp: cannot create regular file ‘/usr/local/bin/some_file.txt’: Permission denied
Run Code Online (Sandbox Code Playgroud)
然后我必须在命令前加上前缀sudo
才能使其工作
$ sudo cp some_file.txt /usr/local/bin
Run Code Online (Sandbox Code Playgroud)
当我执行需要权限的命令时,如何自动获得 sudo 密码提示?
就像是:
$ cp some_file.txt /usr/local/bin
cp: cannot create regular file ‘/usr/local/bin/some_file.txt’: Permission denied
Please enter sudo password:
************ # Entering my password
# Command executed successfully
Run Code Online (Sandbox Code Playgroud) 碰巧我必须在以非 sudoer 的标准用户身份登录时安装新程序。然后我必须从 GNOME 登录显示以另一个用户身份登录,这有点麻烦。
还有另一种方法吗?
如果我以不在 sudoer 组中的标准用户身份登录,则似乎无法发出sudo
命令。我尝试了pkexec
一切,但我能做的唯一方法sudo
是以 sudo 用户身份登录。
我刚刚安装了 Ubuntu,我的用户是一个超级用户,可以使用sudo
. 所以我认为这个用户被添加到/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
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of …
Run Code Online (Sandbox Code Playgroud) 我们的实验室中有一台 Ubuntu 14.04 机器,我的计划是限制/etc
具有sudo
特权的用户更改目录中的任何内容,以便只有 root 用户可以编辑配置文件。
是否有任何软件可以像 Windows 服务器中那样应用此类策略?
我安装了加密的 ubuntu (fullhd) 并且忘记了 root pass 和加密 pass,谁能向我解释一下是否可以恢复这个 HD 中的文件,我真的需要那个
我正在尝试使用sudo
with-S
通过命令行发出密码。
$ sudo -S <<< "mypassword" command
Run Code Online (Sandbox Code Playgroud)
这有效,但它不允许交互式命令。像nano
例如:
$ sudo -S <<< "mypassword" nano /tmp/foo
Run Code Online (Sandbox Code Playgroud)
它会自动关闭 nano 会话。同apt-get
:
$ sudo -S <<< "mypassword" apt-get install foo
Run Code Online (Sandbox Code Playgroud)
它在我可以按“y”安装 foo 之前关闭。我知道我可以通过-y
apt 但总的来说,这令人沮丧。
也尝试过这样的东西,但它仍然无法参与交互式会话:
$ sudo -S <<< "mypassword" -H -u root bash -c "apt-get install foo"
Run Code Online (Sandbox Code Playgroud)
是否可以在-S
不取消所有交互式 shell 的情况下与 sudo一起使用?
基本上我想做的就是标题。如果我想为文件夹中的每个人授予读、写和执行权限,那么我通常会这样做:
sudo chmod -R 777 *
Run Code Online (Sandbox Code Playgroud)
如何扩展此命令以包含隐藏文件和文件夹(以点开头),例如.env
?因为在上面的命令中,这些不受影响。
sudo ×10
permissions ×5
bash ×3
command-line ×3
root ×2
16.04 ×1
apt ×1
chmod ×1
encryption ×1
hidden-files ×1
password ×1
redirect ×1
scripts ×1