[raspberry-vi] Re: Shutting down your Pi

  • From: Tim Chase <raspberry-vi@xxxxxxxxxxxxxxxxx>
  • To: raspberry-vi@xxxxxxxxxxxxx
  • Date: Mon, 14 Oct 2013 10:38:54 -0500

To simplify, you could edit your sudo configuration to include the 2
non-commented lines below which would remove the need to type the
password:

# Cmnd alias specification
Cmnd_Alias SHUTDOWN = /sbin/halt,/sbin/shutdown,/sbin/reboot
# User privilege specification
pi ALL = NOPASSWD: SHUTDOWN

The first command defines an alias for allowable commands (in this
case, "halt", "shutdown" and "reboot").  The 2nd line says that the
user "pi" (change for whatever your username is) can run from
anywhere (the "ALL") whether local or remoted into the machine,
that it doesn't require a password (the "NOPASSWD:"), and the
"SHUTDOWN" references the list of shutdown commands you want.


Depending on your base system, you should either create a file
named "/etc/sudoers.d/50local" which contains those 2 (or 4 if you
include comments) lines, or you can use

  sudo visudo

to edit the main file (which pulls in all files in /etc/sudoers") on
my Debian system.  I recommend the /etc/sudoers.d/50local file method
which survives upgrades better in the event upstream tries to modify
the /etc/sudoers file.

With those changes in place, you can simply issue

  sudo shutdown

and it will shut down without a password.  You could even create an
alias for that in your ~/.bash_aliases or wherever you keep them, and
do something like

  alias die='sudo shutdown'

so you can get away with just typing "die" at the command-line.  Of
course, if you make it too easy to do, then beware of shutting down
when you *don't* intend to. (grins)

Hope this helps,

-tim





=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: