Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Noob here: I have a problem, when i access my server via SSH, the $PATH is correct

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

But when i open my server via XRDP session and go to the terminal it shows an incorrect PATH:

root@ks391320:~# echo $PATH
/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin

Screenshot of both: Screenshot

And this creates an issue because when I try to install something using the "Package Installer" it shows this error (among others)

dpkg: warning: 'ldconfig' not found in PATH
share|improve this question
add comment

4 Answers 4

1

The system-wide default PATH is defined in /etc/environment. First, verify that it's set to a sane value. For reference, here's mine, which is the same as a default install:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

2

If /etc/environment is sane and you're still having issues, you can override the default PATH in ~/.bashrc. For example, I have this in my .bashrc which appends a directory to my PATH if and only if it exists and is not already in my PATH:

if [ -d "$HOME/bin" ]; then
    if [[ $PATH =~ $HOME/bin ]]; then :
    else export PATH="$HOME/bin:$PATH"
    fi
fi

Since it appears from your screenshot that you've enabled root logins, be sure to set root's .bashrc, as well. (By the way, since root can't login by default in Ubuntu, this configuration is presumably less tested and might possibly be related to your problem.)

3

If the first two methods fail, then check whether your XRDP client is doing something exotic. If so, you'll have to either configure it to work normally or identify a way to work around it.

Update

I've been doing some looking around the system. You can find all the places on your system that specify a PATH with the following command (the sudo is there because some files under /etc are unreadable by normal users):

sudo egrep -nr '\bPATH' /etc | less

I think it's safe to ignore many of those places, resulting in the following command:

sudo egrep -nr '\bPATH' /etc | egrep -v '^/etc/(init|rc|ppp|bash_c)' | egrep -v '^Binary' | less

One file that looks possible (though I really don't know too much about it) is /etc/login.defs. You might take a look at it.

In addition, you could grep your dotfiles as well:

egrep -nr '\bPATH' $HOME/.* | less
share|improve this answer
    
The "environment" file is normal, adding the correct paths to ~/.bashrc makes the commands run on the terminal but still not working on the Ubuntu "Package Installer". I couldn't find the root of the problem but i have a solution now, i created a symbolic link in /bin/ to each program required (ldconfig, etc)... this is probably a security breach so i will leave this question open in case anyone haves a better solution. –  Ivan Castellanos Jan 3 '12 at 22:03
    
@IvanCastellanos: I'm not sure what you mean by "package installer," as there's no program with that exact name AFAIK. Could you describe the steps you're taking to install packages? And is this a GUI or command-line installer? –  Scott Severance Jan 3 '12 at 23:23
    
Sorry, i mean "GDebi Packpage Installer" (GUI). –  Ivan Castellanos Jan 4 '12 at 4:45
    
@IvanCastellanos: Do you launch it as gksudo gdebi-gtk /full/path/to/package.deb? I've found it to be a bit picky. If so, then it should inherit the environment it's launched from. –  Scott Severance Jan 4 '12 at 5:49
add comment

Full disclosure: I don't use Ubuntu... but I had the same issue with Debian.

xrdp launches /etc/xrdp/startwm.sh (unless Ubuntu has modified this location). I added this line:

. /etc/profile

to the top of /etc/xrdp/startwm.sh and the PATH is now set correctly.

For Ubuntu, adding

. /etc/environment

to the top of /etc/xrdp/startwm.sh might do the same.

share|improve this answer
add comment

In theory adding

. /etc/environment

would work but it doesn't. I just put it at the top of my .bashrc to correct the problem

share|improve this answer
add comment

Thanks to the previous answers I came to such a solution:

cat /etc/xrdp/startwm.sh | sed "s/. \/etc\/X11\/Xsession/. \/etc\/environment/" > ./startwm.sh && echo ". /etc/X11/Xsession" >> ./startwm.sh && sudo mv ./startwm.sh /etc/xrdp/startwm.sh && sudo chmod 755 /etc/xrdp/startwm.sh

May be not the most optimal but working (Ubuntu 12.04).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.