How to add reboot and shutdown to menu?

I seached the man pages for reboot and shutdown commands but I can only find Quit and Restart. Is it not possible to make a command that reboots the computer or shut it down??

You should read the FAQ – the answer to your specific question is here

– Thomas Adam

Ok I read the FAQ, but I don’t know how to write a shell script. I do have sudo installed and have alsp found a file called sudoers in /etc, but I have not idea what I should put in this file.

Is the sudoers my script file?

A shell script is an ordinary file containing command line instructions. The first line should be


and you will need to set excute permission

chmod +x your_script_name

The script itself needs to be somewhere in your path. You can set

export PATH=$PATH:$HOME/bin

in your .bash_profile, create a directory ~/bin and put the script in there.

sudoers is the file that configures the sudo file. only edit it with the visudo command or bad things may happen.

Ok but what do I need to write in this script if I would like to be able to reboot and shutdown my computer from a menu in FVWM?

I thought I could just add this to a menu:

Exec reboot & # For rebooting.

Exec halt & # For shutdown.

read the man pages for sudo and sudoers

when you have it configured properly you’ll be able to write

exec sudo shutdown

to do what you want.

I read that I needed to use the visudo editor, but I don’t seem to have it…will it be okay to use emacs in root mode instead?

If I make this alias in my sudoers file:

Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown
user ALL=(ALL) ALL

I should the be able to use this command from FVWM right? I will not test it before I know if I can use emacs in root instead of visudo

Nope. The file is fingerprinted to prevent tampering. If you just edit it with a normal editor then the fingerprints don’t get regerated and sudo will refuse to run becuase your sudoers file has been tampered with.

Set EDITOR to emacs and visudoers will run emacs and not vi.

The sudoers entry looks ok. check in /sbin and /usr/sbin for visudo - you shoul have it as part of the sudo package

Where do I set EDITOR? I read that it should be in Environment, but nowhere it is explained what Environment is.

Just bought O’Reilly: Running Linux and it mentions nothing about Environment, its a shame/frustrating that basic books about linux does not have any info on the basic of linux, no wonder a lot of people keeps windows when the most simple and basic information about linux takes hours to to retrieve.

Most of what I have learned is not complicated at all but its just takes forever to find the correct information and is unecessary time consuming.

Well just a few thoughts from a linux newbie

Woah, broadly speaking the environment is the shell in which you type the command, although there are a lot of factors to it besides that. Ideally you should set EDITOR in your ~/.bashrc file – however for the purposes of editing /etc/sudoers, you can do:

EDITOR=“my_program” visudo

Which means trhe variable “EDITOR” is only valid for the duration of ‘visudo’ – usually, one would say EDITOR (as the example of a variable above) is only in the environment if it can be inherited by other shells. For such instances, one would have to ‘export’ this – i.e. put it in an area of memory that is not erased when a shell is fork()ed and exec()d:

export EDITOR=“some_program”

Note that the above construct is the one found common in many ~/.bashrc. In this way, when one types in “bash” (as an interactive shell) the exported variables in the parent shell (the shell which executed the ‘bash’ command) are inherited.


– Thomas Adam

Think of it like this. you can set variables in the shell. Most of these are private to the shell in which you set them. The variables cannot be accessed from subshells or programs started from that shell.

Sometimes though you want this to happen. You want to be able to set a variable that will be passed down through all the processed started from a shell. To do this you export the variable in question

export FOO=bar

Variables that have been exported are often called environment variables because they affect not just the one shell, but the whole environment. Well, if you set the .bash_profile they do, anyway

Ok I now have this in my .fvwm2rc file:

  • “&S. Shutdown” exec sudo shutdown

and this is my sudoers file:

sudoers file.

This file MUST be edited with the ‘visudo’ command as root.

See the man page for details on how to write a sudoers file.

Host alias specification

User alias specification

Cmnd alias specification

Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown


Defaults !lecture,tty_tickets

User privilege specification

root ALL=(ALL) ALL

Added by Ubuntu installer

user ALL=(ALL) ALL

But nothing happens when I chose shutdown from my menu.

Is your username on that box “user”? Somehow I doubt.
If there is a common group in which all users are added, you could use
%groupname in place of user
Otherwise, if your username is, say, “bigblop”, just replace the

Added by Ubuntu installer

user ALL=(ALL) ALL


Added by Ubuntu installer


or, if you have a group called “users”, in which all users are added in ubuntu

Added by Ubuntu installer


(the NOPASSWD -options means no password is asked when sudoing stuff)

EDIT: Ofcourse, if you’re running a server, the above doesn’t make much sense (permitting all “users” to sudo :laughing: )
You could create a special group wheel, and users belonging in that group could have super-user powers at their grasp, and add your own account into that.

I don’t like plugging my own writings, but you can see all of this stuff here: … PseudoRoot

– Thomas Adam

I just entered root and typed visudo -f /etc/sudoers

I the added what you wrote, but now I cannot save the info when I type “:wq” followed by enter.

Is there some bug in visudo?

In case the editor is vi, you can force the save with :w!
Vi (and vim, for that matter) is a world in it’s own, but I guess you could find some quick-start guide from net (or :help)
Also, the plain command “visudo” should suffice

Nothing happens if I write “:w!”. I have read all I can find about save and other basic funtions in VI but nothing covers this problem.

I have just tried to enter root and only type “visudo” then I get the sudoers file and if I make a change I cannot save it. I have tried:


Nothing happens, the commands just get entered in the sudoers file as regular text.

so I guees there is a bug in visudo regarding the save function.

how about EDITOR=emacs visudo as root?

I have now changed to emacs instead. This is how my sudoers file looks like but I still cannot shutdown of reboot from FVWM:

This file MUST be edited with the ‘visudo’ command as root.

See the man page for details on how to write a sudoers file.

Host alias specification

User alias specification

Cmnd alias specification

Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown


Defaults !lecture,tty_tickets

User privilege specification

root ALL=(ALL) ALL

Added by Ubuntu installer


And this is what I have in my .fvwm2rc:

  • “&N. Shutdown” exec sudo shutdown

But nothing happens when I choose Shutdown from my menu.

What am I missing and how do I get another option that only reboots the computer?

can you shutdown or reboot from the command line?