使用 apt-get install 在 $PATH 中添加用户和组

使用 apt-get install 在 $PATH 中添加用户和组

将服务器从 Debian Lenny 升级到 Squeeze 后,我遇到了 dbus 和 vsftpd 更新问题。

我收到以下错误消息(由谷歌翻译从德语翻译而来):

dbus (1.2.24-4 + squeeze1) is set up ...
adduser: No program called "groupadd" in $ PATH directory listing found.
dpkg: error processing dbus (- configure):
  Subprocess post-installation script returned error exit status 1
vsftpd (2.3.2-3 + squeeze2) is set up ...
configured to not write apport reports
                                       addgroup: no program named "groupadd" in $ PATH directory listing found.
dpkg: error processing vsftpd (- configure):
  Subprocess post-installation script returned error exit status 1
configured to not write apport reports
                                       Errors were encountered while processing:
  dbus
  vsftpd
E: Sub-process / usr / bin / dpkg returned an error code (1)

在 $PATH 中找不到 groupadd。我的 PATH 变量是:

-bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory

但是 groupadd 是 /usr/sbin/groupadd,所以根据 PATH 应该可以找到它。但是 echo 还显示找不到文件或目录,但是是哪一个呢?

答案1

您需要修改 /etc/sudoers 配置以包含此行:

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

这是将 sudo 从 lenny 更改为 squeeze。此更改未对您的 sudoers 文件进行,以保留您对 /etc/sudoers 的自定义。

这是来自 /usr/share/doc/sudo/NEWS.Debian.gz 的条目:

The sudo package is no longer configured using --with-secure-path.
Instead, the provided sudoers file now contains a line declaring
'Defaults secure_path=' with the same path content that was previously
hard-coded in the binary.  A consequence of this change is that if you
do not have such a definition in sudoers, the PATH searched for commands
by sudo may be empty.

Using explicit paths for each command you want to run with sudo will work
well enough to allow the sudoers file to be updated with a suitable entry
if one is not already present and you choose to not accept the updated
version provided by the package.

答案2

最后一条错误消息报告说,没有具有该名称的目录或文件 - 即名称为:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

我不知道你最后是怎么想的作为目录或文件名,但它就在那里。要设置 PATH,通常需要执行以下操作:

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

(如果您使用 Bourne Shell 或 C Shell,情况将会有所不同。)

另外,确保您的 /etc/profile 包含合理的 PATH 设置;这是sudo -su -完成时将设置的内容。

请注意,$PATH产生变量的内容PATH;该命令$PATH=/usr/bin:/bin:/usr/local/bin是一个错误。

相关内容