LinuxQuestions.org
Review your favorite Linux distribution.
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-22-2009, 08:31 AM   #1
exsencon
Member
 
Registered: Feb 2008
Location: Belgium
Distribution: Ubuntu,LinuxMint,Slackware,Sabayon,Slax
Posts: 86

Rep: Reputation: 24
Changing to root in konsole-cannot use kwrite


Slackware newbie(and linux as well)
Dell Dimension 520 P4 3GHZ RAM 3GB HD 2*250GB Nvidia GeForce 7300LE
Installed:hd0 WinXP prof
hd1 Ubuntu/Kubuntu,LinuxMint,FedoraFC8,Suse10.3,Sabayon,Mandriva8,
Debian4,Slax6.03,Slackware12.2
Everything running fine with Kubuntu's grub bootloader in the MBR booting every system.
Slackware is running QK now(after a few glitches)but I still have a problem in the konsole.
When I go in as user and want to switch to root to change something using Kwrite or Kate I always getas example)

zeger@HOME:~$ su
Password:
root@HOME:/home/zeger# kwrite /etc/fstab
No protocol specified
kwrite: cannot connect to X server :0.0


So I have to switch user and go in as root and then it's OK.I think I must have done something wrong when adding the user but I have no clue.
Otherwise everything is running fine so far(as far as I can tell)
 
Old 01-22-2009, 08:40 AM   #2
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
No, you did not make any mistakes. In KDE, I edit the K menu (right click on the K menu to get that option), find KWrite under the System header, highlight & copy it, then immediately paste it back. Now you have two entries for KWrite. Select one of them & modify the "command" to add "kdesu " (that's kdesu[space]), without the double quotes, before the command. Also modify the "Name" so that it will be different from the original one, I usually use "KWrite - Root Privileges".
Regards,
Bill

Last edited by TSquaredF; 01-22-2009 at 08:43 AM. Reason: typos
 
Old 01-22-2009, 09:09 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
To add some more detail, the reason it doesn't work is because the root user doesn't have permission to connect to the current user's x-session, and also probably doesn't even have the DISPLAY shell variable set.

Using something like kdesu, or "su -" to log in transfers the the current user's environment settings to root so you can run gui programs. You can also set it manually with the following commands.

To give the local root access permission, run "xhost +localhost" as the user owning the x-session (notice that playing around with xhost can be a security risk).

To set the display variable, run "export DISPLAY=:0" as root (assuming the current display is 0, of course). Now that shell knows how to find the display to use.

To make the settings permanent you need to add them to your bash startup scripts.
 
Old 01-22-2009, 09:15 AM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
And the reason is that you "own" the connection from the server to the display, not "root". The X-server is complicated enough, and adding multiple owners for the same display in the mix, while possible, is not often a problem.

As t^2F said, you can create a menu entry so you own the display while letting root write to it.

Even simpler is to add yourself to /etc/sudoers. Then, instead of su -c 'kwrite <file>' (which won't work), you can do a sudo kwrite file (which will).
 
Old 01-22-2009, 10:40 AM   #5
exsencon
Member
 
Registered: Feb 2008
Location: Belgium
Distribution: Ubuntu,LinuxMint,Slackware,Sabayon,Slax
Posts: 86

Original Poster
Rep: Reputation: 24
OK First I tried to duplicate kwrite and that worked once,but after that and in the same konsole session it didn't work anymore. After I closed the konsole and restarted it even kdesu didn't work (same message)So I rebooted but no result.

Then I added myself to /etc/sudoers and did sudo kwrite /etc/fstab
It works and I can edit fstab but this is what I get:

zeger@HOME:~$ sudo kwrite /etc/fstab
Password:
Error: "/var/tmp/kdecache-zeger" is owned by uid 1000 instead of uid 0.
Error: "/tmp/kde-zeger" is owned by uid 1000 instead of uid 0.
zeger@HOME:~$

I understand that it is owned by me and not by root(uid O)correct?
Should I leave it like that or change something?
 
Old 01-22-2009, 01:30 PM   #6
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
May I take it that you are booting up into run level 4 as booting into run level 3 and running "startx" to start KDE makes what you are trying to do work fine.

To be honest X isn't my field so I don't exactly know what the differences in starting it up my mean. I've been following this thread thinking "That's strange - I do this all the time with no problems." I start in run level 3 however.
 
Old 01-22-2009, 02:45 PM   #7
exsencon
Member
 
Registered: Feb 2008
Location: Belgium
Distribution: Ubuntu,LinuxMint,Slackware,Sabayon,Slax
Posts: 86

Original Poster
Rep: Reputation: 24
Booting up in runlevel 4 indeed which I find easier. I am not sure it has something to do with my problem though; I think it would have been the same with runlevel 3. Anyway it is fixed now.
Thank you all for the help!
 
Old 01-22-2009, 03:02 PM   #8
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
I think it would have been the same with runlevel 3
Nope - definitely doesn't happen when starting in run level 3 then running startx.

I wasn't making this up in my original post you know...

Anyway - glad it's fixed for you.
 
Old 01-22-2009, 06:24 PM   #9
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Those "owned by 1000 not 0" are just warnings that you see because stderr is directed to your terminal. They're safely ignored. (Obviously, you're user number 1000 whilst root is 0.)

[edit]
Oh, a couple additional thoughts:

1) If you want to spawn your sudo session, you need to "activate" the sudo before you spawn the edit session.
2) If you don't want to see the messages, direct stderr to dev/null

Here's an illustration:
Code:
$ sudo echo
[sudo] password for Peter:

$ sudo kate /etc/fstab 2>/dev/null &
7139
$ disown
$

Last edited by PTrenholme; 01-22-2009 at 06:49 PM.
 
Old 01-23-2009, 11:13 AM   #10
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
exsencon:
Quote:
OK First I tried to duplicate kwrite and that worked once,but after that and in the same konsole session it didn't work anymore.
This doesn't sound like the instructions I posted. If you follow my post, you will have an entry in your K Menu right next to the original KWrite entry. Clicking on that entry will bring up a dialog box requesting your root password. After the password is entered, KWrite will start in root mode. Konsole is not involved at all.
Regards,
Bill
 
Old 01-24-2009, 06:43 AM   #11
exsencon
Member
 
Registered: Feb 2008
Location: Belgium
Distribution: Ubuntu,LinuxMint,Slackware,Sabayon,Slax
Posts: 86

Original Poster
Rep: Reputation: 24
Quote:
This doesn't sound like the instructions I posted. If you follow my post, you will have an entry in your K Menu right next to the original KWrite entry. Clicking on that entry will bring up a dialog box requesting your root password. After the password is entered, KWrite will start in root mode. Konsole is not involved at all.
My mistake. I misunderstood. Redid it the way you said and it works like a charm.Thanks
 
Old 01-24-2009, 08:38 AM   #12
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
Quote:
Redid it the way you said and it works like a charm.Thanks
Good, I'm glad it worked. I do the same thing with Dolphin for file management.
Regards,
Bill
 
  


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
How can i run konsole with root? Whynot Linux - Desktop 3 08-12-2007 11:59 AM
konsole acts as "Root Konsole" ab44045 Linux - General 11 06-11-2007 05:18 PM
Changing konsole MilkyBar_Kid Slackware 1 07-22-2004 07:31 PM
opening a file as root in KWrite Moebius Linux - Newbie 4 01-26-2004 06:24 AM
How do i get into root from konsole? AngelLucifer Linux - Newbie 7 11-01-2003 05:23 PM

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

All times are GMT -5. The time now is 07:44 PM.

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