when you use a xrdp client to remotely login to a ubuntu machine, you can find that the environment variables configured in the host machine are not what you can see in xrdp client.
for example, execute the following commands on both host Ubuntu machine and xrdp client machine, repectively.
echo $PATH
echo $JAVA_HOME
you can see that in your xrdp client machine, the second command returns a blank line, and the PATH variable is not identical to the one you can see in host Ubuntu machine.
Solution:
- open the xrdp file
sudo vim /etc/xrdp/startwm.sh
Then, you can see the last line is:
. /etc/X11/Xsession - add the environment setting to xrdp startup file
Just before the last line, add the following line:
. /etc/environment
And save it. . /etc/environment document defines all customized environment variables, it content is like:
JAVA_HOME="/usr/lib/jvm/jdk-1.8.0_11"
JRE_HOME="/usr/lib/jvm/jdk-1.8.0_11/jre"
CATALINA_HOME="/opt/tomcat/apache-tomcat-8.0.9"
AXIS2_HOME="/opt/axis2/axis2-1.6.2"
PATH="/usr/lib/jvm/jdk-1.8.0_11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" - Then, you can start your xrdp client to connect to this Ubuntu machine, then you will see that the PATH variable is the same as you can see in the host Ubuntu machine. However, the other variables are still not exported. To solve this problem, create another file /etc/environment.xrdp, its content is like:
export JAVA_HOME="/usr/lib/jvm/jdk-1.8.0_11"
export JRE_HOME="/usr/lib/jvm/jdk-1.8.0_11/jre"
export CATALINA_HOME="/opt/tomcat/apache-tomcat-8.0.9"
export AXIS2_HOME="/opt/axis2/axis2-1.6.2" - reedit the file /etc/xrdp/startwm.sh, add the following line before the last line:
. /etc/environment.xrdp
save it. - Run the xrdp client again, and you will see all the variables have been successfully imported.
The cause of this problem is that, when you login remotely to a Ubuntu server, the server will load automatically to ~/.profile or ~/.bashrc for the configuration of your environment. If some variables are commonly used by all the users, you can use the above mentioned solution to solve the problem. Otherwise, each user can also customize his/her own environment variable in ~/.profile or ~./bashrc file.
Aucun commentaire:
Enregistrer un commentaire