LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-01-2005, 11:08 PM   #1
thekillerbean
Member
 
Registered: Jan 2002
Location: Melbourne, Australia
Distribution: Ubuntu 22.04 (Jammy)
Posts: 92

Rep: Reputation: 16
Running a command on login.


I once used a Solaris machine that had a special user. The account username was 'shutdown' and the password was 'system.' If you guessed that this user was solely created as a means to allow quick system shutdown by those privy to this info, then you are absolutely correct.

I'm sure that Linux (Red Hat Enterprise Linux 3.0) can do this as well but I have no idea on how to go about it - anyone willing to lend a hand?

Thanks.
 
Old 07-01-2005, 11:44 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
This might give you some hints .
 
Old 07-02-2005, 12:25 AM   #3
carlosruiz
Member
 
Registered: Jul 2003
Location: Japan
Distribution: Mandrake
Posts: 53

Rep: Reputation: 15
A possible approach (not tested):

1. create the user shutdown

useradd shutdown

2. allow user to run init

sudo -u shutdown init

3. create script /home/shutdown/shutdown.sh

#!/bin/sh

# prevent cancellation of execution.
trap "" 1 2 3 6;
# shutdown init 6 for reboot;
init 0;

5. change permission for script.
chmod 700 /home/shutdown/shutdown.sh

4. change the user "shutdown" line in /etc/passwd
from:
shutdown:x:501:501:shutdown_user:/home/shutdown:/bin/bash
to:
shutdown:x:501:501:shutdown_user:/home/shutdown:/home/shutdown/shutdown.sh

login as user shutdown and it must shutdown the PC.


Hope this help, I didn't test it so beware it might not work exactly as it is, but I think it is a good start.

Regards

Last edited by carlosruiz; 07-02-2005 at 12:32 AM.
 
Old 07-02-2005, 01:41 AM   #4
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
If you need to rapidly shutdown your system, why not just
Code:
su
<password>
halt
As a side note, and although it's a bit OT, I think it's worth pointing out that that using the word "system" as the password for an account that has the power to bring down the entire system is a decision that should be reconsidered. It's just too easy to guess, and thus is a security weakness. -- J.W.
 
Old 07-03-2005, 07:57 AM   #5
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Why not just grant normal users the right to shut down the computer by using sudo?
You could create a shutdown group, and any user in the group could shut down the system with:
Code:
sudo /sbin/shutdown -h now
 
Old 07-03-2005, 09:18 AM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Why not use or create the shutdown.allow file?

From the man page of shutdown:

Code:
ACCESS CONTROL
       shutdown can be called from init(8) when the  magic  keys  CTRL-ALT-DEL
       are  pressed,  by  creating  an appropriate entry in /etc/inittab. This
       means that everyone who has physical access to the console keyboard can
       shut  the system down. To prevent this, shutdown can check to see if an
       authorized user is logged in on one of the virtual consoles.  If  shut-
       down  is  called  with  the  -a argument (add this to the invocation of
       shutdown in /etc/inittab), it checks to  see  if  the  file  /etc/shut-
       down.allow  is  present.  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. Currently there is a limit of 32 users in this file.

       Note that if /etc/shutdown.allow is not present,  the  -a  argument  is
       ignored.
 
Old 07-04-2005, 05:07 AM   #7
thekillerbean
Member
 
Registered: Jan 2002
Location: Melbourne, Australia
Distribution: Ubuntu 22.04 (Jammy)
Posts: 92

Original Poster
Rep: Reputation: 16
Thanks y'all. Carlosruiz has what I was looking for. Haven't tried it yet, but should it need any tweaking, I should be able to make it work.

Thanks again for all suggestions. I like the sudo ... solution as well so should tweaking carlosruiz's suggestion not work right, I'll try the sudo thing.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sh command running as nobody chongluo Linux - Security 1 12-01-2004 06:03 AM
Running a command from anywhere tez Linux - Newbie 5 02-27-2004 10:07 PM
Running a console command everytime login... jdaniel Linux - General 1 11-04-2003 03:11 PM
Changin Graphical Login to command line login 3DLirio Linux - Newbie 2 10-16-2003 09:43 PM
command running on cd in Daem0hn Linux - General 3 07-22-2003 03:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration