Page 218 - DCAP602_NETWORK_OPERATING_SYSTEMS_I
P. 218
Network Operating Systems-I
notes If rokcy want to shutdown computer he needs to type command:
$ sudo /sbin/halt
Output:
Password:
Before running a command with sudo, users usually supply their password. Once authenticated,
and if the /etc/sudoers configuration file permits the user access, then the command is run. sudo
logs each command run.
Examples
1. Allow jadmin to run various commands:
jadmin ALL=/sbin/halt, /bin/kill, /etc/init.d/httpd
2. Allow user jadmin to run /sbin/halt without any password i.e. as root without
authenticating himself:
jadmin ALL= NOPASSWD: /sbin/halt
3. Allow user charvi to run any command from /usr/bin directory on the system dev02:
charvi dev02 = /usr/bin/*
How to let normal users shut down the computer in Linux?
Spencer Stirling
This may seem like a stupid issue - why SHOULDN’T the average user be able to turn off his/
her own machine?
The answer is that Linux is inherently designed as a multiuser system. It would generally be a
bad thing if any one user would be allowed to spontaneously turn off the computer while other
users are working. Just imagine what hell would ensue if your webserver were taken down by
some insignificant user halfway across the world.
Of course, it does seem a little overprotective if the user is physically sitting at the machine, since
he/she could just reach over and hit the power button (don’t do that!!!).
There are several schools of thought concerning how to allow a user to shut down a machine
properly. The first method seems somewhat useless to me, but I put it here for completeness.
shutdown.allow
There is a file in /etc called shutdown.allow (and if there isn’t, root can add it). This file contains
a list of users (1 per line) who are allowed to shutdown the computer.
This doesn’t mean that these users can invoke the shutdown (or reboot or halt) command(s).
Instead, it means that an authorized user can shut down the computer by pressing ctrl+alt+del.
In order for this to occur, the ctrl+alt+del key sequence must be trapped in the /etc/inittab file.
The necessary line in inittab is
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
When ctrl+alt+del is pressed, init checks if there is an authorized user (listed in /etc/shutdown.
allow) logged into any virtual console, and proceeds to shutdown if this is true.
Of course, if I’m running X windows, then generally the window manager will trap ctrl+alt+del
for itself, so this won’t work anymore.
212 LoveLy professionaL university