在shell中运行命令时(例如sudo apt-get install aptitude),这是输出:
dpkg: warning: 'ldconfig' not found in PATH or not executable.
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
dpkg: 2 expected program(s) not found in PATH or not executable.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
这是我设定的变量:
export PATH=$PATH:/usr/local/sbin:/usr/local/bin in bashrc
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" in /etc/environment
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" in /etc/sudoerds
echo $path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/node/node:/usr/local/sbin:/usr/local/bin
sudo echo $path
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/node/node:/usr/local/sbin:/usr/local/bin
答案 0 :(得分:1)
尝试sudo su -
并直接从root运行相同的命令,看看它是否通过。
如果它不起作用,还将/root/.bashrc文件中的PATH变量设置为更安全。
/root/.bashrc中
export PATH=/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
这只是环境变量问题,除非那些二进制文件实际上是丢失的,这是不可能的,你永远不会知道其他环境:)
答案 1 :(得分:0)
谢谢,这对我有用!
nano /root/.bashrc
转到最后一个并输入:
export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin
在更新bashrc之后,请执行以下操作:
. /root/.bashrc
或 来源/root/.bashrc
答案 2 :(得分:0)
我在这里偶然发现了类似的情况。因此,如果有人受益,我将添加此答案。
Debian从8升级到9.9后收到此错误。我正在使用sudo apt-get install...
安装docker并收到以下错误
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)
我通过编辑下面的/etc/profile
文件来修复了该问题,
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
到
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
fi
更改与else
旁其他用户的PATH变量相对应的root
部分,添加缺少的路径。
Original Source(西班牙语)