LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-20-2008, 10:18 AM   #1
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794
Blog Entries: 2

Rep: Reputation: 30
Emacs not starting as root


For some reason emacs won't work as root user in kde. This has always been a problem, but as I don't normally use kde, I've never solved it. It launched fine as a normal user. As root user user I get this error:

/home/simon# emacs /etc/lilo.conf
No protocol specified
emacs: Cannot connect to X server :0.0.
Check the DISPLAY environment variable or use `-d'.
Also use the `xhost' program to verify that it is set to permit
connections from your machine.


I don't have this problem unless I'm running kde, so it must be something to do with that. kde also seems to mess about with other settings, such as mouse pointer buttons, but I've solved that. I can run it like this:

emacs -nw

But not otherwise. In what way does kde affect the display setting? Also, I'm now using run level 4 instead of 3, so it might be kdm doing this.
 
Old 01-20-2008, 10:52 AM   #2
cuk
Member
 
Registered: Jun 2004
Distribution: slackware 10.2.
Posts: 39

Rep: Reputation: 15
root can't use X apps per default

You have 2 options:
Either run emacs in console mode: emacs -nw
or allow root to use X programs: xhost +
Regards
 
Old 01-20-2008, 11:13 AM   #3
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794

Original Poster
Blog Entries: 2

Rep: Reputation: 30
emacs -nw isn't ideal.

Trying to add root via xhost isn't working.
/home/simon# xhost + root
No protocol specified
xhost: unable to open display ":0.0"


What I'm wondering is, why this is happening. I can't be the only person who uses emacs as root user in kde, and the kdm login manager. I'm pretty sure it's to do with kdm.
 
Old 01-20-2008, 11:29 AM   #4
jimX86
Member
 
Registered: Mar 2006
Distribution: Slackware64 -current
Posts: 268
Blog Entries: 1

Rep: Reputation: 79
I think that display managers use the .Xauthority file. You could probably change that using the merge command option of xauth. But I would just try entering:

kdesu emacs
 
Old 01-20-2008, 11:36 AM   #5
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794

Original Poster
Blog Entries: 2

Rep: Reputation: 30
Thanks, kdesu does work. This is one of the reasons I don't use kde.
 
Old 01-20-2008, 11:43 AM   #6
cuk
Member
 
Registered: Jun 2004
Distribution: slackware 10.2.
Posts: 39

Rep: Reputation: 15
Hi,
Code:
xhost +
disables acces control for all,
if you want only root the correct form is not
Quote:
xhost + root
but
Code:
xhost +local:root
Hope it helps...
 
Old 01-20-2008, 01:08 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by simcox1 View Post
Thanks, kdesu does work. This is one of the reasons I don't use kde.
Now this kind of suggests that you're actually working as
your normal user, and were trying to open a GUI program
from a terminal after you've su-ed to root. If this is the case
ALL GUI tools should be giving you the same error message.

It's not a KDE fault, just a common security feature.


Cheers,
Tink
 
Old 01-20-2008, 01:21 PM   #8
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794

Original Poster
Blog Entries: 2

Rep: Reputation: 30
That's right. I su to root and launch the program from the console. How else do I use a text editor as root? Close down X first?
 
Old 01-20-2008, 01:26 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Well, no. Under KDE kdesu is indeed the proper way of doing that.

Under fluxbox you'd have to do the (last time I did it worked) a
"xhost +localhost:root" as your OWN user, and then in the terminal
you're in as root a "export DISPLAY=localhost".

Personally for system related editing I use vi these days ;} (and used
to use emacs -nw in the past - no point in getting used to GUI when
half the time you're doing it via ssh over bad lines ;D).


Cheers,
Tink
 
Old 01-20-2008, 01:49 PM   #10
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794

Original Poster
Blog Entries: 2

Rep: Reputation: 30
In fluxbox I always su to root. I didn't need to export the display, although su- didn't work as expected. It only seems to affect emacs. Vim works fine.
 
Old 01-20-2008, 02:01 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
The difference between 'su' and 'su -' (which is probably what you'd want
when becoming root) is that su will preserve your environment - hence no
need to export anything - while 'su -' will create roots environment, and
the need for the exporting of DISPLAY.


Cheers,
Tink
 
Old 01-20-2008, 02:13 PM   #12
jimX86
Member
 
Registered: Mar 2006
Distribution: Slackware64 -current
Posts: 268
Blog Entries: 1

Rep: Reputation: 79
simcox1, if you start X from runlevel 3, su will behave just like you are expecting it to behave. (Whether in KDE or fluxbox.)

Runlevel 4 with a display manager is a different situation.
 
Old 01-20-2008, 02:32 PM   #13
simcox1
Member
 
Registered: Mar 2005
Location: UK
Distribution: Slackware
Posts: 794

Original Poster
Blog Entries: 2

Rep: Reputation: 30
I see, so it is kdm that is causing it. I'll use emacs -nw, or kdesu then, if I stick with kde. I thought I'd just try it as I haven't used it in a while. The auto mounting is nice. Thanks.
 
  


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
Unable to open emacs as root mikieboy Debian 3 01-09-2007 11:29 PM
can't run emacs as root resist_r Linux - General 1 10-07-2005 05:54 PM
cant use emacs in root any more? |2ainman Linux - General 1 04-19-2004 09:07 PM
root emacs problems spuppett Linux - Newbie 2 04-13-2004 02:20 AM
emacs won't load as root cuzzle Linux - Software 3 03-05-2004 12:49 PM

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

All times are GMT -5. The time now is 10:18 AM.

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