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 get:(as 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) |
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 |
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. |
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). |
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? |
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. |
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! |
Quote:
I wasn't making this up in my original post you know... Anyway - glad it's fixed for you. |
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 |
exsencon:
Quote:
Regards, Bill |
Quote:
|
Quote:
Regards, Bill |
All times are GMT -5. The time now is 08:34 AM. |