LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-12-2009, 06:13 AM   #1
lgp171188
LQ Newbie
 
Registered: Apr 2009
Posts: 16

Rep: Reputation: 0
Creating user account which on login shuts down the computer


I want to create an unprivileged user account, say 'shutdown', which can be used only to shutdown the system. I followed the instructions in http://www.cyberciti.biz/tips/shutdo...ux-server.html. But when I login into the system, I get this error 'Cannot execute /usr/bin/sudo /sbin/shutdown -h now: No such file or directory'.

These are the configurations that I did

/etc/sudoers:

Code:
shutdown localhost=/sbin/shutdown -h now
/etc/passwd:
Code:
shutdown:x:999:0:shutdown:/sbin/:/usr/bin/sudo /sbin/shutdown -h now
I guess the shutdown binary and/or the /sbin folder is out of access for the shutdown user. How am I to get it right?

Thanks in advance.
 
Old 08-12-2009, 07:38 AM   #2
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
why don't put the shutdown command directly in the root's crontab?


59 8 * * * /sbin/shutdown -h now

Last edited by shahz; 08-12-2009 at 07:41 AM.
 
Old 08-12-2009, 09:56 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,705

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
Please put your distro & version in your profile for better help.
Quote:
'Cannot execute /usr/bin/sudo /sbin/shutdown -h now: No such file or directory'.
usually means what it says: one or more of those cmds isn't where you think it is, or permissions have been set such that the user can't see those cmds.

Try

which sudo
which shutdown

and

ls - l

the results
 
Old 08-13-2009, 12:25 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by lgp171188 View Post
I want to create an unprivileged user account, say 'shutdown', which can be used only to shutdown the system. I followed the instructions in http://www.cyberciti.biz/tips/shutdo...ux-server.html. But when I login into the system, I get this error 'Cannot execute /usr/bin/sudo /sbin/shutdown -h now: No such file or directory'.

These are the configurations that I did

/etc/sudoers:

Code:
shutdown localhost=/sbin/shutdown -h now
/etc/passwd:
Code:
shutdown:x:999:0:shutdown:/sbin/:/usr/bin/sudo /sbin/shutdown -h now
I guess the shutdown binary and/or the /sbin folder is out of access for the shutdown user. How am I to get it right?

Thanks in advance.
Last field should be command, not command with args

So you can use
/etc/passwd:
Code:
shutdown:x:999:0:shutdown:/sbin/:/sbin/my_shutdown
And create in the /sbin shell script my shutdown
Code:
#!/bin/sh
/usr/bin/sudo /sbin/shutdown -h now
And by the way, why do you want shutdown user unprivileged ?
Anyway this user do nothing but shutdown system, so I think you can
make shutdownn user with uid 0 and don't use sudo

Last edited by Valery Reznic; 08-13-2009 at 12:29 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with creating user account.. apexofhorizon Linux - General 2 07-26-2007 07:11 AM
Creating a new user account swamprat SUSE / openSUSE 2 09-12-2006 03:50 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 11:02 AM
FC4-test1 not creating a User Account - Cannot Login DigeratiPrime Fedora - Installation 1 03-17-2005 08:41 PM
creating user account Robin01 Linux - Newbie 2 01-25-2004 02:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration