LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to use sudo access in GUI (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-sudo-access-in-gui-610220/)

Rustylinux 12-31-2007 04:04 PM

How to use sudo access in GUI
 
Hello,

I was wondering if someone could inform me on how you would go about using sudo in Gnome and KDE. I usally use the terminal personally but I had a friend that is new to linux asking me a bunch of questions and I couldn't answer that one for him, needless to say he didn't like my "just use the terminal answer"

So how does one do this in Gnome and or KDE. He is currently using Gnome with Nautilus, however I'm sure the time will come when he messes around with KDE as well.

Thanks!

XavierP 12-31-2007 04:11 PM

kdesu for Kde and gksudo for Gnome - as in "kdesu <program name>" or "gksudo <program name>". The Kde command requires the root password though.

https://launchpad.net/kdesudo will be a KDE frontend for sudo once complete.

jay73 12-31-2007 04:19 PM

Having root access just like that would beat the purpose of sudo. It would be dumbing down Linux to what windows is in the hands of most people: a system where pretty much anything goes. But if that is the only option, one may as well pick a system that allows one to log in as root and work under the root account all the time. No good but, well, I'm sure you already know that. The alternative is modifying one's menu entries in such a way that you a message box popping up to request the root password first. That would be equivalent to the sort of behaviour that one sees when one selects a task from the menu that requires root permissions (say, the Firewall menu item). I haven't seen any need for this but I imagine it could be achieved relatively easily using gksu or gksudo.

Rustylinux 01-02-2008 09:58 AM

Hello,

I guess what I'm trying to ask is, i don't want to run as root I just want to know how you would do a sudo in the GUI much like if I where in the terminal trying to copy some files around and it said permission denied I would sudo my cp and away I go. How would you do something like this in the GUI.

For instance, lets say I want to copy a file from my desktop into a folder somewhere in my directory structure and it gives me a access denined. How would you accomplish the same effect as doing a sudo in the terminal execpt in the Gnome GUI without logging in as root ?

jay73 01-02-2008 01:53 PM

In that case, you could install a file manager (something like midnight commander, for example) and then edit the menu entry: if that entry has "gksudo command" instead of simply "command", it will pop up an authorization box before launching the application. Once you have submitted proper authorization, the file manager will give you all the access that you would get from sudo in a CLI.

Rustylinux 01-02-2008 03:52 PM

Quote:

Originally Posted by jay73 (Post 3008779)
In that case, you could install a file manager (something like midnight commander, for example) and then edit the menu entry: if that entry has "gksudo command" instead of simply "command", it will pop up an authorization box before launching the application. Once you have submitted proper authorization, the file manager will give you all the access that you would get from sudo in a CLI.

Ahhh thanks for the info, I will have to give this a try. Do you know if Gnomes File Manager by default has such abilities built in. As i know Gnome by default loads gksudo and u can run that from the teraminal but you can't right click on a file and run it, or run it from the menu systems.

hand of fate 01-02-2008 04:03 PM

Quote:

Originally Posted by jay73 (Post 3008779)
In that case, you could install a file manager (something like midnight commander, for example)...

Why would you need to install a file manager? Both KDE and Gnome include a file manager, so anyone running one of those systems will already have one.

What I do is enter "konqueror" in the KDE Run Command panel, check "Run as a different user", and enter "root" and my root password in the respective boxes. If you need to do this repeatedly then you could create a menu item that runs your file manager of choice as root (in fact some distributions have such a menu item by default).

MoonMind 01-02-2008 04:24 PM

Rustylinux:

You can change any menu item to read gksudo [application] (or kdesudo ...) instead of [application]; if you configure the /etc/sudoers file in the right way (it probably is already), the confirmation box mentionned above pops up. But I think it'd be important to explain to the guy in question that he should limit himself to the system administration tasks he's meant to use until he's got a little experience - as soon as he's root (or doing things as if he were root) and goes trying out stuff, he can - and probably will - mess up things; of course, this can be desired for pedagogical purposes... Just make sure your not the guy who has to fix things in that case, then ;) Anyway, if he's becoming aware of the fact that not being root is a win in many cases (security-wise) he can be taught what is necessary in due time. That may sound conservative and patronising, but from supporting distributions that didn't erect that extra barrier I know what harm can come from careless usage of root privileges (and I know many who'd agree).

However, if he's really put off by the need to enter a password, you can change the /etc/sudoers file accordingly. I normally wouldn't, but I have used (and supported) systems that are configured that way because a lot of new users (coming from WinDoze) expect it to be that way. If they're sensible enough about it (and are used to locking their terminal when they leave it), it's not too bad, but still a security risk. All in all, the better behaved (experienced?) a user is, the less will she/he feel the need to become root on a daily basis (if she/he's not a sysadmin, but that's a completely different story).

hand_of_fate:

I think that precisely this simple approach is perceived as "complicated" by many WinDoze users... I always have an xterm open for all purposes, and it's great for just about everything, but I know for a fact how intimidating this is for people who're not used to the CLI. Heck, it literally keeps certain people off my box altogether :D

M.

jay73 01-02-2008 04:38 PM

Quote:

Why would you need to install a file manager?
Yes, of course, KDE and Gnome already have file manager. Now, I don't know about KDE but the Gnome run command box (Alt + F2) does not have an option to specify the user to run as. So you are down to two options: either you modify the permissions on your file manager but then you run with root permissions all the time - not very secure - or you install an alternative file manager that you only use when you have a need to. But now that I think about it, I am sure that it would be possible to add a menu item for an "enhanced" nautilus that is launched from the menu (command: gksudo nautilus). This would give you a second nautilus that, unlike the default one, allows you to do about anything. I just tested this on my Fedora box from the command line and it appears to work fine. In order to make it work from the menu, you just create a new menu entry, name it "root file manager" or something like that and you specify the command as "gksudo nautilus".

hand of fate 01-02-2008 05:12 PM

Quote:

Originally Posted by jay73 (Post 3008935)
Yes, of course, KDE and Gnome already have file manager. Now, I don't know about KDE but the Gnome run command box (Alt + F2) does not have an option to specify the user to run as.

The KDE one certainly does. I don't use Gnome, but even if it doesn't have that option you could still enter "gksu nautilus" or "gksudo nautilus" into it.

Quote:

Originally Posted by jay73 (Post 3008935)
either you modify the permissions on your file manager but then you run with root permissions all the time

It's nothing to do with the permissions of the file manager. The issue is whether the permission of the files to be modified allow the user that the file manager is being run as to modify those files.

Quote:

Originally Posted by jay73 (Post 3008935)
or you install an alternative file manager that you only use when you have a need to.

Any program (including any file manager that is already installed) can be run as any user that has permission to run it. Root by definition has permission to run any executable program. Why does the file manager you run with root permissions have to be different to the one you run without?

Quote:

Originally Posted by jay73 (Post 3008935)
But now that I think about it, I am sure that it would be possible to add a menu item for an "enhanced" nautilus that is launched from the menu (command: gksudo nautilus).

It's not really an "enhanced" program. It's the same program as "regular nautilus", just running as a different user.

jay73 01-02-2008 05:23 PM

Quote:

The KDE one certainly does. I don't use Gnome, but even if it doesn't have that option you could still enter "gksu nautilus" or "gksudo nautilus" into it.
Quote:

Why does the file manager you run with root permissions have to be different to the one you run without?
I'm afraid that you don't seem to get the point. The idea is that we need to start our file manager without any CLI commands. That is not what we do when we start the file manager from the command line or from a run command box. And if we start nautilus from the menu, we can't have it behave one way this time and another way the next time. We do need separate entries.

Quote:

It's not really an "enhanced" program. It's the same program as "regular nautilus", just running as a different user.
Yeah, true, but I thought the quotation marks made it clear that "enhanced" shouldn't be taken literally.

Quote:

It's nothing to do with the permissions of the file manager
Bad phrasing on my part. I was referring to using (gk)sudo to launch the file manager, which is something else. But of course, you are right.

hand of fate 01-02-2008 06:51 PM

Quote:

Originally Posted by jay73 (Post 3008978)
I'm afraid that you don't seem to get the point.

What "point" may that be. The "point" that you "need" to install another file manager even though the one you've already got is perfectly capable of doing what you need? Since this statement is completely untrue, it is not a valid point.


Quote:

Originally Posted by jay73 (Post 3008978)
The idea is that we need to start our file manager without any CLI commands.

If you create a menu item or icon to run the file manager as with root permission, you can then use that menu item or icon "without using any CLI" (in so far as you can do anything without using any CLI. What exactly does clicking on an icon do if it doesn't invoke a command behind the scenes?)

Quote:

Originally Posted by jay73 (Post 3008978)
And if we start nautilus from the menu, we can't have it behave one way this time and another way the next time. We do need separate entries.

You only need separate menu entries, not a completely separate program. I don't know where you got the idea that you can't have menu items for same program with and without "gksudo" in front of it, but it's definitely not true. It's entierly possible (for example) to have one item for "nautillus" and another for "gksudo nautilus".

Quote:

Originally Posted by jay73 (Post 3008978)
Bad phrasing on my part. I was referring to using (gk)sudo to launch the file manager, which is something else. But of course, you are right.

Why do you think that the only options are to always launch the file manager using (gk)sudo or use a completely different program when you need sudo? A far more obvious solution is to run the file manager of your choice with sudo when you need it, and the same program without sudo when you don't.

jay73 01-02-2008 09:39 PM

Sigh, this is going to be a great year. You know you are the second one in two days to misrepresent what I wrote only to make an argument out of it? A lot of people appear to be very,very bored these days. Here is what I wrote only a few posts ago:

Quote:

But now that I think about it, I am sure that it would be possible to add a menu item for an "enhanced" nautilus that is launched from the menu (command: gksudo nautilus). This would give you a second nautilus that, unlike the default one, allows you to do about anything.
But apparently you thought it was more important to fuss over the word "enhanced" than to look past it at what was really meant. And just in case, here is something else I wrote:

Quote:

I thought the quotation marks made it clear that "enhanced" shouldn't be taken literally.
I don't know if you read a lot but if you do, you should know that this is one of the things that quotation marks communicate. And don't start harping on the word "second" because that is what it is, you can perfectly have multiple instances of a single program running simultaneously.

Quote:

A far more obvious solution is to run the file manager of your choice with sudo when you need it, and the same program without sudo when you don't.
So what do you think I have been suggesting?? Only you seem bent on doing the first from the CLI while I was simply suggesting a solution that wouldn't force the user to do so.

So what is next? Are you going to object that the menu is, in fact, only a front-end to the terminal???

rikxik 01-03-2008 03:06 AM

Oh man - the poor guy just needs to do gui operations in privileged mode.

@RustyLinux

Basically, your friend needs an icon/launcher/menu entry (you get the idea) on which he can click and launch Nautilus (since you mentioned he is using Gnome, Nautilus is the default file manager). So just get him to do this:
--
1. Right-click on the desktop
2. Choose "create launcher" (I may be missing the exact term). This will basically create a shortcut.
3. A dialog box pops up with fields to enter the name of the shortcut, the description and the command to be executed when this is double-clicked
4. Enter "sudo nautilus" (without double quotes) in the command field. Enter whatever you like in the name, description section.
5. Thats it - click ok and you have an icon on your desktop - you double click on it to launch nautilus which will run in privileged mode.
--
Just ask him to use it sparingly.

HTH

hand of fate 01-03-2008 10:42 AM

Quote:

Originally Posted by jay73 (Post 3009162)
So what do you think I have been suggesting??

I "think", in fact I know (the proof is right here in this thread) that you have been suggesting that the user installs an extra file manager that they don't need.

Quote:

Originally Posted by jay73 (Post 3009162)
Only you seem bent on doing the first from the CLI

First of all, I am in no way "bent on" anything. I stated what solution I use (the "Run Command" panel), which I have every right to do. I also suggested another solution (adding menu item).

Secondly, at no point did I even make any mention of using the CLI.

Quote:

Originally Posted by jay73 (Post 3009162)
while I was simply suggesting a solution that wouldn't force the user to do so.

You suggested for no explicable reason that the user installs an additional file manager that they do not need. I correctly pointed out that this is not necessary.

I am doing a service to anyone reading this thread by saving them the effort of installing an extra file manager for no reason. Some credit for this service would be appreciated, and would certainly be more appropriate than your constant argument.


All times are GMT -5. The time now is 01:21 PM.