I have used gksu -w shutdown -hP now as a system-wide menu command in icewm, so that when a non-admin user clicked the shutdown from the menu, a password dialogue box will appear asking for the admin password. That was when I was running icewm in Linux Mint.

When I switched to Ubuntu, the same command wouldn't work. Although the same dialogue box asking for admin password appears, but none of the existing sudoers password I tried would work or accepted. Even the password of the first account I was asked to make on installation of Ubuntu wouldn't work.

I have also tried gksu -u admin-user -w 'shutdown -hP now, but the error message "shutdown: Need to be root" came up.

So what is the difference between Ubuntu's and Mint's gksu rules? I'm currently using Ubuntu 12.04 LTS, and the Mint I'm referring to is Mint 13 Maya. And what could be other alternative ways to allow a Shutdown command in the IceWM menu for non-admin users, but I still want them to ask permission first from me before they could shutdown, by asking for my admin password?

Besides shutdown, I also have other commands in the IceWM menu that require admin privileges, like hibernate, to mount a backup partition, and synaptic, which I applied gksu -w with.

  • Since its asking for the password, I'd just check to see the output of the command. Try gksu -w shutdown -hP now > /tmp/gksu-output and see what it says. That might be the best way to find out why its not working. Aug 26 '13 at 1:14
  • I just tried ...same thing, 'didn't accept the admin-user password, and it did not say anything. The file /tmp/gksu-output is empty, when I opened it. Aug 26 '13 at 1:53
  • Are you sure the user you are using is in the admins and sudo group? You may want to add it to those groups using sudo usermod -G <admin-username> admin and sudo usermod -G <admin-username> sudoers and try again. Aug 26 '13 at 10:58
  • No, the user shouldn't be in the sudo group. It really happens in Mint, where a standard user uses this command and a dialogue box asking for the administrator password appears, then I supply any of the administrators' password, and it works. I just can't figure that out here in Ubuntu. But I like it here in Ubuntu, 'coz programs runs more responsive and quicker. Aug 26 '13 at 11:09
  • <Deleted since you are using gksu and not gksudo> Aug 26 '13 at 11:15

The problem:

  • gksu -w will ask for your root password, however the root user does not have a password by default in Ubuntu, so everything you try will fail.

  • gksu -u admin-user -w will execute shutdown as admin-user, but you need to be root, not admin-user.

The possible solutions are two:

  1. Use gksu -u admin-user -w gksu -S. Which means: first switch to admin-user (gksu -u admin-user -w), then become root (gksu -S).

  2. Set a password for the root user. This way, gksu -w will work as you expect.

The drawback for the first solution is that you will be asked for two passwords, which may be uncomfortable. The drawback for the second solution is that enabling the root user is not recommended.

  • Gee! Thanks, Andrea! Does that mean that in Mint they set a password to root? Now, I'll be able to add the system-wide rootmenu options on our icewm, that are admin-access only. Thanks again and God bless. Aug 26 '13 at 14:09
  • @JosephDomingoTibiEnsano: I'm not a Mint expert, however Googling it seems that yes: they set a root password. Aug 26 '13 at 14:15
  • Isn't it possible to add special priviledges for sudo, just for the shutdown commands precisely? It actually is if you wish. This way, sudo (and gksudo, gksu and other similar ones) will allow those commands directly. Apr 18 '16 at 19:54
  • (although it seems that in the question the real problem is a polkit misconfiguration, that is, the priviledges for shutdown/... are not used, or icewm is not made aware of policykit) Apr 18 '16 at 19:55
  • 1
    @PaulStelian: yes, indeed. You have to edit the sudoers file (using visudo) and add a line like this: user ALL=(ALL) NOPASSWD: /sbin/shutdown. You can even add arguments if you want the rule to be more restrictive Apr 19 '16 at 7:34

I would reccommend using gksudo and not gksu although they aren't very different in Ubuntu. Just add the 'admin-username' to the 'sudoers' or 'admin' group or just give it access to the shutdown command in the /etc/sudoers file.

Then instead of gksu -w <admin-username> <command> you could use gksudo <command>. Again the whole point of having sudo/gksudo is to have users be able to do administrative tasks without giving them full blown root access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.