Jump to content

Shutdown Linux Without Sudo


Recommended Posts

Posted

Is there a way to give a user right to shut down/reboot a Linux server nicely on local console without giving them sudo root access?

Posted

This is the shutdown info on my server:

"shutdown can check to see if an authorized user is logged in on one of the virtual

consoles. If shutdown is called with the -a argument (add this to the invocation of

shutdown in /etc/inittab), it checks to see if the file /etc/shutdown.allow is pre-

sent. It then compares the login names in that file with the list of people that

are logged in on a virtual console (from /var/run/utmp). Only if one of those

authorized users or root is logged in, it will proceed. Otherwise it will write the

message

shutdown: no authorized users logged in

to the (physical) system console. The format of /etc/shutdown.allow is one user

name per line. Empty lines and comment lines (prefixed by a #) are allowed. Cur-

rently there is a limit of 32 users in this file.

"

Posted

It also depends on your Linux distribution... Red Hat (I seem to recall) and Fedora (what I use now) have a program /usr/bin/halt which is enabled with pam-console functionality so it automatically allows the local console user to request halt commands, which normally require root permission. This only works when invoking /usr/bin/halt, and not the other one in /sbin/halt. The command "halt -p" is equivalent to "shutdown -h now".

Also, on any recent ACPI-capable machine, /etc/acpi/events/power.conf can be configured to do shutdown using the power button on the computer. You may need to install the "acpid" package if it is not already installed, and make sure it is configured to start on system boot. The following is the content of the relevant file on my Fedora 7 laptop. This tells the system what to do when the power button press is detected...

# ACPID config to power down machine if powerbutton is pressed, but only if
# no gnome-power-manager is running

event=button/power.*
action=/bin/ps awwux | /bin/grep gnome-power-manager | /bin/grep -qv grep || /sbin/shutdown -h now

This pays attention to gnome-power-manager because it provides a GUI method of causing a shutdown, and when it is running it will detect the power button press and prompt the user whether they really want to shutdown... On such a system, you could simplify the action line to just:

action=/sbin/shutdown -h now

If you want the power button to ALWAYS mean shutdown, regardless of the state of the GUI system.

  • 3 weeks later...
Posted

What are the consequences of shutting down a modern Linux system simply using the power-switch?

My employer ships a couple of products that rely on the Linux OS, and not once has any customer ever complained about a corrupt file system upon rebooting. My employer does not want the customer to think that they are dealing with a computer, but instead a simple device that is turned-on when needed and shut-off when it is not. Sometimes at the office, we cycle power in a moments notice (to reboot) and there are no file system glitches whatsoever.

Therefore, I suppose a "graceful" shutdown (whether using halt, shutdown, reboot, or ctrl-alt-delete) is needed only when data preservation of running applications is needed; for cases where it is not, simply shutting off the power should suffice. Am I correct?

Btw, the systems my employer ships is HDD based, not RAM and Flash Memory like in embedded systems.

Posted
What are the consequences of shutting down a modern Linux system simply using the power-switch?

Therefore, I suppose a "graceful" shutdown (whether using halt, shutdown, reboot, or ctrl-alt-delete) is needed only when data preservation of running applications is needed; for cases where it is not, simply shutting off the power should suffice. Am I correct?

If you are running linux servers like I am which means disk activity most of the time with multi-users and no way of knowing at what state it is in, it is a recipe for file corruption. If a workstation where a user has control over what is happening and all activities initiated by the user it is less of a problem. But still, not a good idea to do a hard power off.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.



×
×
  • Create New...