LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-29-2002, 05:48 PM   #1
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Rep: Reputation: 30
How to Run an Application as root without a log off?


Dear All,
I know this sounds like a question that has been asked many a times before, but there is a serious twist in it, so please humor me and reas on.

Firstly, the set up:

Distro: SuSE Linux 7.3 Professional
kernel: 2.4.10-Gmbh (yes its old, working on recompiling the new one)
Video Card: Nvidia GeForce 2 MX 400 AGP 4x 64MB

Things to know before describing the problem:
I have just downloaded the latest video drivers from Nvidia.com and installed them for my distro (SuSE 7.3)


Now the problem:
I wish to be able to run an application as root without having to log off /log back on and/or restart the X server.
I tried using su - and it logged me in fine, but when I try to launch an application I receive the following error:

Gtk-WARNING **: cannot open display:


Here are examples to illustrate this better:

Example 1: (quoted and bolded for readability_
Quote:

samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # xcdroast

Gtk-WARNING **: cannot open display:
suse_or_bust:~ #
Example 2: (quoted and bolded for readability)
Quote:


samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # xmms

** CRITICAL **: Unable to open display
suse_or_bust:~ #

Please reply if you can help. Your replies are well appreciated before hand
 
Old 05-29-2002, 07:40 PM   #2
verigoth
Member
 
Registered: May 2002
Posts: 179

Rep: Reputation: Disabled
here's what you need to do:

# su -
Password:
# export PATH=$PATH:/usr/X11R6/bin:/opt/gnome/bin:/opt/kde/bin (or where kde/gnome are installed)
# export DISPLAY=localhost:0
# xmms

verigoth
 
Old 05-30-2002, 01:50 PM   #3
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
Thanx for the reply. I have tried the steps you mentioned and I still got an error. Here is the run, bolded and quoted for readability

Quote:

samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # export PATH=$PATH:/usr/X11R6/bin:/opt/gnome/bin:/opt/kde/bin
suse_or_bust:~ # export DISPLAY=localhost:0
suse_or_bust:~ # xcdroast
Xlib: connection to "localhost:0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key

Gtk-WARNING **: cannot open display: localhost:0
suse_or_bust:~ #
Note that export PATH seemed to have worked (as no errors where shown).

Please reply if you can help.

Thanx for the replies beforehand
 
Old 05-30-2002, 02:43 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well that's nothing to do with logging off or anything, you simply haven't allowed external access to your X sessions. run "xhost +root" and try again.
 
Old 05-30-2002, 05:50 PM   #5
verigoth
Member
 
Registered: May 2002
Posts: 179

Rep: Reputation: Disabled
damn...new i forgot something thanks

verigoth
 
Old 05-30-2002, 06:58 PM   #6
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
Nope, Still no can do. Same error message. Here is a test run for you to see my results (bolded and quoted for readability)

Quote:

samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # export PATH=$PATH:/usr/X11R6/bin:/opt/gnome/bin:/opt/kde/bin
suse_or_bust:~ # export DISPLAY=localhost:0
suse_or_bust:~ # xhost +root
Xlib: connection to "localhost:0.0" refused by server
Xlib: Client is not authorized to connect to Server
xhost: unable to open display "localhost:0"
suse_or_bust:~ # xmms
Xlib: connection to "localhost:0.0" refused by server
Xlib: Client is not authorized to connect to Server

** CRITICAL **: Unable to open display
suse_or_bust:~ #
Also, If i try to do the xhost +root first, it still doesn't work. For example:
Quote:

samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # xhost +root
xhost: unable to open display ""
suse_or_bust:~ #
Can anybody please help? This is driving me nutts!
 
Old 05-30-2002, 11:23 PM   #7
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
Try running xhost +root before you execute su -. If +root doesn't work, try +localhost.
 
Old 05-31-2002, 09:13 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well naturally it's the person that OWNS the X server that is the only one who can allow external connections...
 
Old 05-31-2002, 11:59 AM   #9
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
hmm, Still not making sense. As user "samer" I gave localhost access to the X server. Now as root it STILL complains about connectiong to the XServer. Here is the run, bolded and quoted for readability

Quote:

samer@suse_or_bust:~> xhost +localhost
localhost being added to access control list
samer@suse_or_bust:~> export PATH=$PATH:/usr/X11R6/bin:/opt/gnome/bin:/opt/kde/bin
samer@suse_or_bust:~> export DISPLAY=localhost:0
samer@suse_or_bust:~> su -
Password:
suse_or_bust:~ # kedit
kedit: cannot connect to X server
suse_or_bust:~ #
 
Old 05-31-2002, 12:05 PM   #10
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
For Future Reference, I got this to work. I'm sure someone else may have similar problems, so here is a Qui Guide to What I did
1.) Open up a a Konsole/bash prompt.
2.) type in "xhost +localhost" without the quotes. This should say something like: "localhost being added to access control list"
3.)Log in as root with "su -" and type in your password
4.)type in "export PATH=$PATH:/usr/X11R6/bin:/opt/gnome/bin:/opt/kde/bin" without the quotes. You may need to change this if you installed your KDE in a different directory
5.)type in "export DISPLAY=localhost:0"
6.)Now you can run programs as root without a log off!

NOTE: This will NOT work if you simply save the steps to some file and give it executable permissions. If anybody knows a way to get it to work as such, please let us Know. I tried it that way and it gave me a
Quote:

** CRITICAL **: Unable to open display

Last edited by shassouneh; 05-31-2002 at 12:14 PM.
 
Old 05-31-2002, 12:13 PM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
does the file HAVE to be called graxs?
the path statement should not be related to your situation, and should be done in a different scope to the system. if you need executables in there you should add it to roots path. And of course using su in a script file is a pretty daft thing to do really.

You should also be able to creaet a permanent X host access file, as defined in "man xhost" which will make these changes permenent, rather than using a redundant script each time to do exactly the same thing.
 
Old 05-31-2002, 12:16 PM   #12
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
Acid, I edited my message above. Frankly I'm the only user using this machine, and I don't want to keep logging off/on to access a program as root. I tried doing the executable file for the heck of it and It didn't work as mentioned above. If you know how please explain how I can generate such a script to make thkings permenant and allow running a program as root on the fly. Thanx for all the replies everyone. They are much appreciated.
 
Old 05-31-2002, 12:31 PM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well putting aside the issue that i don't like the idea, there's no simple way really... running su will start a new shell, and the remaining commands will not be executed until you exit that shell. a way around the issue would be to go down the line of something as equally icky as

xhost +whoever/wherever
su -c 'set something; something else; xterm'

that should then open a x terminal ready for use as root.. but it's not really too nice.
 
Old 05-31-2002, 01:15 PM   #14
shassouneh
Member
 
Registered: Apr 2001
Location: Cheney, WA
Distribution: SuSE Linux Professional 9.2
Posts: 556

Original Poster
Rep: Reputation: 30
I see. I guess I can just stick to copy/paste and copy the exports as mentioned on this post, LOL. I understand your concern from the viewpoint of security, and I kinda also don't like doing it since Im not going to be always running on my machine. However, it is a quick and dirty way to do things.
For security puposes, I'll type in (or paste in) everything myself.

By The way, I tried doing it without the export Path..... and just doing the export DIPLAY= .... thingy and it worked too
 
Old 06-02-2002, 01:11 PM   #15
verigoth
Member
 
Registered: May 2002
Posts: 179

Rep: Reputation: Disabled
just to clarify my reasoning: in Slackware (not sure about any other distro), when you su to root, your path is limited to /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin. if you wanted to run any executable not in any of those places you would have to change the path. not knowing where the application shassouneh wanted to run resided, i said to change the path.

verigoth
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to enable root to run graphical application in user log in xgreen Slackware 4 03-07-2005 06:39 AM
Cant only log in as root after user log-in. ADJenkins Linux - General 2 11-17-2004 04:18 PM
Log Out root Then Log In As Other User xtremcoder Linux - General 4 10-04-2004 11:01 PM
Log on as Root, or switch to Root, in MDK 9.1 - KDE 3.1.0 snorky Mandriva 3 09-01-2003 12:07 PM
I can run application with root Rex_chaos Linux - General 5 03-28-2002 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:46 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