LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   dpkg: `file' not found on PATH. (https://www.linuxquestions.org/questions/debian-26/dpkg-%60file-not-found-on-path-318831/)

utw-mephisto 04-30-2005 03:02 PM

dpkg: `file' not found on PATH.
 
Hi,

I am quite new in Debian and a "professional" friend tried to help me with something. The result : A messed up system.

When installing packages with apt-get I get the following errors :

Code:

.
.
Fetched 619kB in 1s (354kB/s)
.
.
Preconfiguring packages ...
dpkg: `ldconfig' not found on PATH.
dpkg: `start-stop-daemon' not found on PATH.
dpkg: `install-info' not found on PATH.
dpkg: `update-rc.d' not found on PATH.
dpkg: 4 expected program(s) not found on PATH.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)

When executing the following commands, I can install the programs with apt-get again:

Code:

root@debian:~# export PATH=$PATH:/usr/local/sbin/
root@debian:~# export PATH=$PATH:/usr/sbin/
root@debian:~# export PATH=$PATH:/sbin

However, this is working only once.

I checked the file /root/.profile which contains the following :

Code:

# ~/.profile: executed by Bourne-compatible login shells.

if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

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

mesg n

It looks actually fine, doesn't it ? I am really lost, any help is highly appreciated ...

Dead Parrot 04-30-2005 09:27 PM

I haven't had any PATH related problems using Debian. Then again, I've never logged in as root -- I always login as normal user and then use "su" to become "superuser" that has root privileges.

If that doesn't help, you should perhaps check /etc/login.defs. In my login.defs there are these lines that appear to be important in defining PATH:
Code:

#
# *REQUIRED*  The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH      PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games


utw-mephisto 04-30-2005 09:34 PM

Mmm.... login.defs looks good actually :(

Dead Parrot 04-30-2005 10:43 PM

Maybe you should try "echo $PATH" both as normal user and as superuser to find out if the problem only exists when you "su" to root.

Also, ~/.bash_profile (or ~/.profile) defines only login shell while ~/.bashrc defines other (non-login) shells that you open afterwards. So, if the problem only appears in non-login shells (like in terminal window), then you could try to add PATH in ~/.bashrc to see if that helps.

utw-mephisto 04-30-2005 11:09 PM

Quote:

Originally posted by Dead Parrot
Maybe you should try "echo $PATH" both as normal user and as superuser to find out if the problem only exists when you "su" to root.

Also, ~/.bash_profile (or ~/.profile) defines only login shell while ~/.bashrc defines other (non-login) shells that you open afterwards. So, if the problem only appears in non-login shells (like in terminal window), then you could try to add PATH in ~/.bashrc to see if that helps.

Ok, echo $PATH gives me

Code:

root@debian:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

Which means sbin is indeed missing. Where else can I set these ? It is correctly set in /etc/login.defs

Dead Parrot 04-30-2005 11:51 PM

This probably depends on your login method. If you use a "display manager" (kdm, gdm, wdm, or xdm), then it's possible that PATH is defined in the display manager's config file. I use wdm and PATH for both normal users and the superuser is defined in /etc/X11/wdm/wdm-config. (I think that for gdm the config file is /etc/gdm/gdm.conf but I don't know about the other display managers.) If you use the command line to login, then such files as /etc/login.defs, /etc/profile, and /etc/bash.bashrc should define system-wide login settings that can be changed with the login files (.profile, .bash_profile, and .bashrc) in user's home directory.

If your problem appears during X session (in terminal window) after starting the session with "startx", then adding /sbin to PATH in .bashrc may help. Make it something like this:
Code:

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

Or, alternatively, you could try to make root user's .bashrc to read .profile (where /sbin apparently is mentioned) by adding this to root's .bashrc:
Code:

if [ -f ~/.profile ]; then
  . ~/.profile
fi


utw-mephisto 05-01-2005 12:00 AM

I am using only Putty to connect to the server ..

I have tried both and still :

root@debian:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

Dead Parrot 05-01-2005 01:05 AM

Hmm... I don't know the reason, but your problem seems to be that you're getting normal user's PATH while you're the root user. So maybe you should edit normal user's login files and make their PATH identical with root user's. In /etc/login.defs, you can change ENV_PATH to be identical with ENV_SUPATH. If you have made a normal user, you can also edit .bash_profile and .bashrc in the normal user's home directory to contain the same PATH that is set in root user's .profile. Then logout and login again to see if "echo $PATH" now has /sbin. If this still doesn't help, then I'm afraid that I'm running out of suggestions. :(

utw-mephisto 05-01-2005 01:47 AM

Thanks a lot guys,

what I did now is :

/root/.bash_profile
export ISU_HOME="/var/www/isu"
export PATH=$PATH:/sbin/
export PATH=$PATH:/usr/sbin/
export PATH=$PATH:/usr/local/sbin/
export PATH=$PATH:/sbin
export PATH=$PATH:/usr/sbin
export PATH=$PATH:/usr/local/sbin
[/b]

And :

Code:

root@debian:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/sbin/:/usr/sbin/:/usr/local/sbin/:/sbin:/usr/sbin:/usr/local/sbin

:D

One question though :

Do I put the path with [/ {slash}] at the end or without ?

Dead Parrot 05-01-2005 07:08 AM

It's great that you found a working solution at last. :)
AFAIK, the slash at the end of the export command is not necessary -- it shouldn't have any effect on the actual command if you add the slash mark or if you leave it out.

mkenyon2 08-07-2008 09:22 AM

I know I'm late to the game, but I'm having a similar problem.

However, all my paths are correct, so I don't know what the issue is.

I think it's how dpkg was installed.

I'm using DSL-N, and got dpkg on the system with a myDSL extension that was written for DSL.

Any experience with this?

smund3 10-21-2011 07:53 AM

I am fully aware that this is an old thread, but as this thread is the first hit I got while Googleing this issue, I will provide a sollution for users who have disabled login as root:

Add this line to your /home/[user]/.bashrc file:
Code:

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


All times are GMT -5. The time now is 12:05 AM.