LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 05-31-2009, 10:20 AM   #1
milomak
Member
 
Registered: May 2009
Posts: 147

Rep: Reputation: 18
xserver and su


how can i go about using programs that need X while using su -
 
Old 05-31-2009, 10:51 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
From konsole or terminal... (?)

or with kdesudo or something like that

man kdesudo
 
Old 05-31-2009, 12:05 PM   #3
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid/RPIOS
Posts: 4,884
Blog Entries: 28

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
KDE kdesu
Gnome or any other DE gksu or sux
or you can use sudo if you have it set up.
 
Old 06-01-2009, 10:23 AM   #4
milomak
Member
 
Registered: May 2009
Posts: 147

Original Poster
Rep: Reputation: 18
looking to do it from a console (ie within whatever DE).

So I would be looking to setup something where I could the following for instance:

Code:
# su -
# gparted
 
Old 06-01-2009, 04:50 PM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally Posted by milomak View Post
looking to do it from a console (ie within whatever DE).

So I would be looking to setup something where I could the following for instance:

Code:
# su -
# gparted
That normally won't work as is: when you use su with the minus option, it tells su that you want to discard all the environment variables for the current session, and start a whole new login. Unfortunately, the DISPLAY environment variable is used to tell the X program which X server to use.

One option is to use plain "su" without the minus option, but then any configuration files will probably be written to the home directory of the user who invoked the program, which isn't ideal. Another option, as others have suggested, is to use an appropriate X-aware sudo frontend to run the program. gksu and sux will do a su - and keep just the DISPLAY variable.

You can also do it by working directly from the terminal. First, before you type su, you need to find out what your display environment is:
Code:
$ echo $DISPLAY
This will normally return "localhost:0.0", meaning the local machine, first (0-based) display, first (0-based) screen. ("localhost" is implied if omitted, so you may just see ":0.0").

Then run your command as root, setting the DISPLAY variable:
Code:
$ su -
# export DISPLAY=localhost:0.0
# gparted
You can also modify DISPLAY for the regular user account using export. For example, you can run commands on other X servers running on other computers on the network (see the man-page on the xset command for how to set this up). Or you can use /etc/inittab to set up multiple X sessions on different virtual terminals and use the display number to choose which one to use (ctrl+alt+f7/f8/f9 etc to switch between them).

If you are asking this because you are connecting into another computer using ssh and want to run commands as root, but have them display on your local computer, then you can pass the -X option to ssh, which will set up the port-forwarding and handle xset for you, and set DISPLAY - but you will still need to remember to change DISPLAY when you use su.

Hope that helps,

—Robert J Lee
 
Old 06-17-2009, 03:10 PM   #6
milomak
Member
 
Registered: May 2009
Posts: 147

Original Poster
Rep: Reputation: 18
Something is amiss

Code:
root ~ # echo $DISPLAY

root ~ #
 
Old 06-18-2009, 12:31 PM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Milomak,

Judging from your code block, you are logged in as root and do not have a display variable set. There may be several reasons for this; you could have run a script to open a root shell that doesn't keep the DISPLAY variable, you could have used "su -" to obtain the shell, or there may even be no xserver running.

The easiest way to run gparted, as others have said, is to open a normal (non-root) terminal, and type "sux gparted".
 
Old 06-18-2009, 01:49 PM   #8
milomak
Member
 
Registered: May 2009
Posts: 147

Original Poster
Rep: Reputation: 18
Yeah it was a schoolboy error on my part

Code:
milomak ~ $ echo $DISPLAY
:0
milomak ~ $ su -
Password:
root ~ # export DISPLAY=localhost:0.0
root ~ # gparted

(gpartedbin:29012): Gtk-WARNING **: cannot open display: localhost:0.0
root ~ #
I mostly use sux - now, but that causes another problem by not picking up

Code:
if [ -f /etc/bash_completion ]; then
     . /etc/bash_completion
fi
from /etc/profile.
 
  


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
xserver lost configuration, dpkg-reconfigure xserver-xorg isn't helping bezdomny Linux - Software 5 07-13-2008 12:33 PM
help with xserver ankurd Linux - Software 13 02-22-2007 05:39 AM
xserver-xfree86: Xserver could not start on my ATI-radeon video card Shankarrajus Debian 2 07-17-2006 07:00 AM
xserver-xorg config warning: migrating xserver-xfree86 templates doctorwebbox Debian 9 07-27-2005 07:24 PM
XServer EvLwMn Linux - General 10 02-23-2003 01:34 PM

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

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