Enabling graphical display by switching user from the terminal.

First of all, the guys at smc (Swathanthra Malayalam Computing) is so totally cool. They are like, waiting for helping you out with something. Really helpful people there. Ershad, Rag Sagar (whom I got to know yesterday just because of the doubt I posted in their mailing list), Jaseem, Praveen, only to mention a few.

Not only that, but it is wonderful to see how easily the world is connected today. Within a few seconds, people from Pune, Bangalore, Calicut and Malappuram talked together and solved a certain Linux administrative problem, which I am going to describe below.

I was trying to learn git and as such, wanted to experiment on managing pull requests. I did not wish to bother anyone else with the task of sending me a pull request and hence, I created a new user in my system. There were two options for me to do it. Whether to use useradd or adduser.

useradd, it seems, is the primitive Unix command of creating a user. I guess you could put it like “raw create user”

On the other hand, adduser, was a perl script that used useradd, and also other informations to create your new user account for you.

Hence, I went along with the latter and created my user. I switched to my new user account using

$su newuser

However, when I tried to open/create a file within the home directory of the newuser with the command

$gedit test.c

I got the following errors:

No protocol specified
No protocol specified
Cannot open display:
Run ‘gedit –help’ to see a full list of available command line options.

Which meant that the graphical display was not working for the new user. Without much delay, I posed the question on the smc mailing list and got two answers:

1. The twisted way proposed by Ershad. He he…

To ssh into the new user account with the -X parameter so that you can use the graphical display. For this, you need to install openssh-server and do:

$ssh -X newuser@ (Or you could use ‘localhost’ instead of ‘’ if the mapping is there in your /etc/hosts file)

You are good to go. However, he mentioned that this was not the right way to do things and wanted to find how to do it right. It was then that Rag Sagar pinged me online (since he was not able to reply to the thread due to some technical difficulties). He provided me with the second way, which was the ‘right’ way it seems!

2. The right way by Rag Sagar.

As root, run the following

$xhost local:newuser

Switch to newuser account

$su – newuser

Voila! Now you can use the graphics as you wish. Note the ‘‘ sign in the su command. It stands there for giving the environmental settings for the new user as expected when logging in directly with the new user account. Need to dig up more information on how that works.

And xhost, it seems, is the program that decides/allows who all can access the X server. (What!?). Got to get more info on this as well.

Well, that is the adventure that I had yesterday. Now gitting back to git.


One thought on “Enabling graphical display by switching user from the terminal.

  1. Pingback: Today's Linux Server LinksNine OM

Hey! What do you think? Share your thoughts. :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s