Debian或者Ubuntu操做系统下,安装软件时,出现以下报错vim
Preconfiguring packages ... dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. dpkg: error: 2 expected programs not found in PATH or not executable. Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin. E: Sub-process /usr/bin/dpkg returned an error code (2)
PS:简单来讲,解决办法就是:在用户~/.bash_rc中,PATH路径设置一下便可 或者 在/ect/sudoers设置sudo的安全路径便可
问题重点:安全
dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
These errors have been reported several times by Debian and Ubuntu users (you can actually Google them for more information).
It seems like the PATH variable isn't correctly set when the user tries to execute a command through sudo, which is probably what you are trying to do.
这里有三种解决方案:bash
Solution 1: 设置 sudo 默认安全路径操作系统
编辑 /etc/sudoers by running vim /ect/sudoers in your terminal, 保证/ect/sudoers更新为下面:code
Defaults env_reset Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Solution 2: 直接使用root帐户,记住使用root帐户,/root/.bashrc中的PATH设置为orm
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
不要使用sudo,只需切换root到运行命令。运行如下命令之一来执行此操做:terminal
$ sudo -i $ su
以root身份登陆后,只需apt-get再次运行命令:get
# apt-get ...
您可能必须首先设置root PATH。编辑/root/.bashrc(固然使用root权限),并添加如下行:io
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Solution 3: 在执行sudo时,传递PATH变量给sudo。table
只需在sudo调用前加上PATH变量的从新定义:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin sudo apt-get
就是执行sudo命令前,加上PATH=/usr/local/sbin ... 一堆环境变量路径