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 ... 一堆環境變量路徑