Using Ubuntu 14.04 with Unity. I log in with my usual user (admin) in graphic environment. Once logged, I'd like to run GUI-commands like if I were another user (normal), to test a client-server application. I need several users (one for server and another for each client), because each one needs an own $HOME
environment. In the future, they are supposed to be installed in separate machines.
So, I open a terminal and I do:
su - user
When I run any GUI command (such as 'xterm'), it tells the usual
No protocol specified
Cannot open display:
I read several ways to solve this using xauth
, xhost
, etc., but the one that worked for my purposes was:
admin# sudo cp ~/.Xauthority ~user/.
admin# sudo chown user ~user/.Xauthority
admin# su - user
user$ export XAUTHORITY=~/.Xauthority
Now I can run any GUI command, such as xterm
.
However this solution, only works within same GUI session. Once you reboot computer, .Xauthority
file changed, and this solution is no longer valid, unless I copy .Xauthority
again, which is tedious and involves sudo commands to copy.
So, is there a way, to make it persistent within .bashrc
or some other way? I mean, once I open a terminal from GUI and log in using su -
, would be capable to run commands that require GUI without have to do all previous stuff.
Sorry for English.
No comments:
Post a Comment