Shutdown From GDM without Typing Root Password
Saturday, September 24th, 2005On the default Debian 3.1 setup, you need to be root to shut your computer down. This makes sense on a server but is a nuisance on a desktop machine.
To enable ordinary users to shutdown without having to type the root password, you need to use sudo which allows named users to run certain commands as if they were root.
The configuration file /etc/sudoers is edited by root with the tool visudo. Since visudo uses vi as the default editor you may want to change this unless you’re comfortable with its somewhat cryptic interface.
Your default editor is controlled by the $VISUAL variable. To permanently set your default editor as root edit /root/.bashrc and add the line export VISUAL=/usr/bin/joe, replacing joe (my favourite) with your own favourite console editor: /bin/nano is installed by default on Debian and is simple to use.
Now that you’re ready to edit, run visudo. You could edit the file directly but visudo has two added benefits: it prevents more than one person trying to edit the configuration file at the same time and more importantly it provides syntax checking when you finish editing and warns you if you’ve made any mistakes.
In the section headed # User privilege specification add: tim ALL = NOPASSWD:/sbin/shutdown -[hr] now (Obviously replace “tim” with your own username!)
Now you will be able to run shutdown as an unprivileged user without having to enter a password. Remember that /sbin will not be in your $PATH so type /sbin/shutdown -h now to run it.
Once this is working, you are ready to enable shutdown in gdm. Edit /etc/gdm/gdm.conf and change the line SecureSystemMenu=true to read SecureSystemMenu=false. You will no longer need to enter the root password when you select the Shutdown or Restart options in the gdm drop down menus.
