Bug repair: dpkg cannot find ldconfig/start-stop-daemon


When installing software under Debian or Ubuntu operating system, the following errors occur

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: Simply put, the solution is: in the user ~/.bash_rc, the PATH path can be set or the sudo security path can be set in / ECT / sudoers.
Key issues:

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.

There are three solutions:

Solution 1: Set sudo default security path

Edit / etc / sudoers by running VIM / ECT / sudoers in your terminal, and ensure that / ECT / sudoers is updated as follows:

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

Solution 2: Use the root account directly, remember to use the root account, / root /. bashrc PATH is set to

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Don’t use sudo, just switch root to run commands. Run one of the following commands to perform this operation:

$ sudo -i
$ su 

Once you log in as root, you only need apt-get to run the command again:

# apt-get ...

You may have to set up root PATH first. Edit / root /. bashrc (using root privileges, of course) and add the following lines:

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

Solution 3: Pass the PATH variable to sudo when sudo is executed.

Just add a redefinition of the PATH variable before the sudo call:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin sudo apt-get

Before executing the sudo command, add PATH=/usr/local/sbin… a bunch of environment variable paths

Recommended Today

[tutorial] restful API using JWT authentication in laravel

This article is forwarded from the professional laravel developer community, original link: https://learnku.com/laravel/t… In this article, we’ll learn how to use JWT authentication to build restful APIs in larevel. JWT stands for JSON web tokens. We will also use the API to create full-featured crud applications for user products. When using cross platform applications, the […]