LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 08-10-2007, 11:06 AM   #1
dcroxton
Member
 
Registered: Apr 2004
Distribution: Ubuntu Jaunty
Posts: 91

Rep: Reputation: 16
xhost +localhost doesn't work


I have two problems with xhost that have been bothering me ever since I started using Ubuntu back at Hoary. I would really like to find a solution to them.

(1) The command "xhost +localhost" doesn't work. It says it works, but I cannot open graphical applications as the root user (e.g., synaptic). The only way I can get it to work is to use "xhost +", which everyone emphatically says you shouldn't do.

(2) I want to allow root to run graphical programs automatically, so I don't have to issue an xhost command every time. This seems pretty basic. I've seen the suggestion to put the xhost command in xinitrc, but that does not work. Even when I insert the line "xhost +", I still start out unable to run graphical programs as root until I type "xhost +" in a shell.

I've found several other threads about xhost on LQ, but none of the solutions work for me.

Thanks for any help.
 
Old 08-11-2007, 08:27 AM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
For (1), try
Code:
xhost +local:
 
Old 08-11-2007, 11:19 AM   #3
dcroxton
Member
 
Registered: Apr 2004
Distribution: Ubuntu Jaunty
Posts: 91

Original Poster
Rep: Reputation: 16
Well, daggone, that worked. I had found that in another thread and tried it (I have it in my .bash_history to prove I'm not imagining things) and it didn't work. It was shown as "xhost +LOCAL:" in that thread, but it works with or without caps.

Thanks for your help. Now, if I could only get this to work on bootup.
 
Old 08-11-2007, 11:24 AM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
You can't do it on bootup, since this is a user-specific setting and your user isn't logged on at that point. It must be done in a user-specific area, such as ~/.bash_login or ~/.bashrc.
 
Old 08-11-2007, 01:35 PM   #5
dcroxton
Member
 
Registered: Apr 2004
Distribution: Ubuntu Jaunty
Posts: 91

Original Poster
Rep: Reputation: 16
This brings up another thing I've never figured out: how to run something on login. This was important to me at one time because I wanted to be able to distinguish between times that I actually logged in, versus times that the computer turned itself on in order to record a show in MythTV.

I put a "touch .loggedin" in .bash_login, but it never got executed. My understanding (limited as it is) is that .bash_login only gets executed when you initially log in, not when you run an interactive shell. It didn't work in either case for me. I can put it in .bashrc and it works, but only in an interactive shell, not when I log in via the graphical login.

So, if you could help me figure out how to get .bash_login to work, or what other file I need to use, that would be a big help.

Thanks again.
 
Old 08-12-2007, 03:26 AM   #6
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Quote:
Originally Posted by dcroxton
This brings up another thing I've never figured out: how to run something on login.
Assuming you use Gnome and a graphical login, you need to configure GDM do do what you want.

For example, on Ubuntu 7.04, I've added "xhost +local:" to /etc/gdm/Init/Default, just before the final "exit 0" line, logged out and back in, and that worked. It's not user-specific though, but you could add a test to execute it only for a certain user.

Read up on GDM and its configuration (I'm a KDE user so I don't know Gnome or GDM too well).
 
Old 08-12-2007, 03:42 AM   #7
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Or, more elegantly, in Gnome go to System->Preferences->Sessions, and in the Startup Programs tab, press New and add the "xhost local:" command there.
 
Old 08-13-2007, 12:19 PM   #8
dcroxton
Member
 
Registered: Apr 2004
Distribution: Ubuntu Jaunty
Posts: 91

Original Poster
Rep: Reputation: 16
Great, thanks for your help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't forward X with ssh without xhost +localhost deimya Slackware 6 06-01-2007 10:22 AM
Problem with "xhost +localhost" not staying set Nylex Linux - General 2 12-29-2005 09:55 AM
xhost +localhost has no effect anymore maenho Linux - Software 2 11-16-2004 08:57 AM
xhost localhost ALWAYS true_atlantis Slackware 1 05-21-2004 08:45 AM
How to permanently add localhost via xhost? h00chman Linux - Newbie 1 04-23-2004 11:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 10:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration