UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.