Debian This forum is for the discussion of Debian 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-15-2004, 05:18 PM
|
#1
|
|
LQ Newbie
Registered: May 2004
Location: Israel
Distribution: n/a
Posts: 14
Rep:
|
Can't run X apps as root
Code:
michael@debian:~$ su -
Password:
debian:~# gedit
(gedit:1242): Gtk-WARNING **: cannot open display:
debian:~# synaptic
(synaptic:1243): Gtk-WARNING **: cannot open display:
debian:~# kedit
kedit: cannot connect to X server
debian:~#
If I log as root from gdm i can run X applications, but not with 'su'.
Last edited by michaely; 07-15-2004 at 05:23 PM.
|
|
|
|
07-15-2004, 05:50 PM
|
#2
|
|
Member
Registered: Dec 2003
Distribution: Debian, FreeBSD
Posts: 310
Rep:
|
Just use sudo instead.
|
|
|
|
07-15-2004, 06:27 PM
|
#3
|
|
Member
Registered: Jun 2004
Distribution: Debian
Posts: 46
Rep:
|
Try this
I use this in my .bashrc file
" xauth merge /home/username-of-non-root-user/.Xauthority "
" export DISPLAY=:0 "
That should get it working. If you are not logged in on an X session as that user then you will see an error when you log in as root from a console, because the user is not using X at the moment. The error can be ignored.
|
|
|
|
07-16-2004, 01:03 PM
|
#4
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,568
|
I just got a nice tip from Dead Parrot that solves this problem nicely. Check it out in my thread here:
http://www.linuxquestions.org/questi...hreadid=204095
|
|
|
|
07-16-2004, 01:38 PM
|
#5
|
|
Senior Member
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513
Rep:
|
Another easy way to do it is too put this in your /root/.bashrc.
Code:
# Allows me to run an X program as root
export XAUTHORITY=/home/stephen/.Xauthority
You would of course change the line to your user name.
|
|
|
|
07-16-2004, 06:17 PM
|
#6
|
|
Senior Member
Registered: Aug 2003
Location: Upstate
Distribution: Debian, ubuntu
Posts: 1,153
Rep:
|
I wrote a little script to give root permission to run X programs:
Code:
#! /bin/sh
xhost local:root
xterm -T "Run X Programs as Root" -geometry 100x20 -e dialog --title \
"Run X Programs as Root" --msgbox "Root can now open X programs. \
Press enter to continue. . . ." 9 50
I have this script saved as the file runXroot in my /home directory. I made it executable with "chmod +x runXroot" On my KDE desktop, I created a link to open the application with the command "/home/matt/./runXroot" Now when I need to run a program as root, I just click on the button on my desktop. The script pops up a dialog that informs you that root now has permission.
Of course, the method above given by Stephen is easier and makes the change happen every time you log into X. However, some people may not want root to have permission to run X programs all the time.
Last edited by m_yates; 07-16-2004 at 06:28 PM.
|
|
|
|
07-16-2004, 06:46 PM
|
#7
|
|
Senior Member
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513
Rep:
|
Quote:
Originally posted by m_yates
Of course, the method above given by Stephen is easier and makes the change happen every time you log into X. However, some people may not want root to have permission to run X programs all the time.
|
It is not every time you log into X it would only give the person who is listed in the line permission to do so when using su in a console window to go to root so they have to have the root password anyways. If you have not logged into X as that person then it would not apply and this includes root at the console the normal users Xauthority who is listed would not exist.
|
|
|
|
07-17-2004, 04:37 AM
|
#8
|
|
LQ Newbie
Registered: May 2004
Location: Israel
Distribution: n/a
Posts: 14
Original Poster
Rep:
|
Now I'm actually using Slackware 10.0 (I'm in a proccess of finding the "right" distro for me) and I have the exact problem.
I tried adding
Code:
export XAUTHORITY=/home/stephen/.Xauthority
to my .bashrc file but there are two problems:
1. I don't have .bashrc in my home dir (niether in root's homedir).
2. I created a .bashrc file and put this line in it, but it did not help. Actually, after adding this line in .bashrc I could no longer run X apps even when I was logged as root (gdm and gnome did load, however), so I removed this line.
I will try RunLevelZero's solution.
About Dead Parrot's solution, as I mentioned before I'm using slack10 right now and I have Xorg not XFree86, so I'm not totally sure what to do here:
Quote:
I did some digging and found several recommendations from Debian developers to use xauth instead of xhost. Here's one trick that sounds very nice (although, again, I haven't tried it myself): Create a file /etc/X11/Xsession.d/10xfree86-common_su and make it include these lines:
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
|
Should I just replace '10xfree86-common_su' with '10xorg-common_su' - will it simply work? Worth a try I guess, don't think it will brake something (emphesize on think)
|
|
|
|
07-17-2004, 05:29 AM
|
#9
|
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
michaely:
If you're the only user of your computer, you should try this
# ln -fs /home/your_username/.Xauthority /root/.Xauthority
The more complicated solutions are only needed for multiuser computers.
|
|
|
|
07-17-2004, 11:13 AM
|
#10
|
|
LQ Newbie
Registered: May 2004
Location: Israel
Distribution: n/a
Posts: 14
Original Poster
Rep:
|
I just tried it, and restarted X, but no good... same problem.
edit: Tried also RunLevelZero's solution, no good either :\
Last edited by michaely; 07-17-2004 at 11:20 AM.
|
|
|
|
07-17-2004, 11:42 AM
|
#11
|
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
Did you remember to log out after making xauth changes? Also, did you check that you don't have any xhost entries in your startup files? I've been told that setting xhost overrides any xauth settings.
Edit:
If our suggestions don't seem to help, you can do some experimenting in xterm to find out whether any of these suggestions works at all. If one of the experiments described below works, you only need to figure out which startup file you need to use to execute this working solution. If none of these experiments will work, you must look for some other solution.
Before you start experimenting, remove all the changes you've made to the startup files (both in your home directory and in root user's directory). Then log out, login again, start X as usual, and launch xterm.
1.
$ xauth merge /home/your_user_name/.Xauthority
$ export DISPLAY=:0
$ su
# [launch X application as root user]
2.
$ export XAUTHORITY=/home/your_user_name/.Xauthority
$ su
# [launch X application as root user]
3.
$ xhost local:root
$ su
# [launch X application as root user]
4.
$ xhost +localhost
$ su
# [launch X application as root user]
Note: In xterm you can return from root user to normal user quickly by pressing simultaneously the hot key combination "Ctrl" and "d".
Last edited by Dead Parrot; 07-17-2004 at 04:51 PM.
|
|
|
|
07-17-2004, 04:26 PM
|
#12
|
|
Senior Member
Registered: Aug 2003
Location: Upstate
Distribution: Debian, ubuntu
Posts: 1,153
Rep:
|
The command: Will work on Slackware as well as Debian to give root permission to open X programs. That is the command I have in the script posted above. In Slackware, it should be possible to add that command to a local startup script. You should try adding it to the .xsession file in the users directory to see if that works.
|
|
|
|
07-18-2004, 04:03 AM
|
#13
|
|
LQ Newbie
Registered: May 2004
Location: Israel
Distribution: n/a
Posts: 14
Original Poster
Rep:
|
Dead Parrot, I need to login/out each time before I try each solution in xterm?
|
|
|
|
07-18-2004, 04:47 AM
|
#14
|
|
Senior Member
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597
Rep:
|
Quote:
|
I need to login/out each time before I try each solution in xterm?
|
No need for that because you run the commands directly from xterm (and not from the startup files that are read during login). Just make sure you've removed any earlier xauth and xhost settings so that they don't interfere with your little experiments.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:59 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|