LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2014, 06:18 AM   #1
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209
Blog Entries: 1

Rep: Reputation: Disabled
How to reboot server by sudoer user?


My user name is in sudoer file
check ALL=(ALL) ALL
But, when I want to restart server by check user the error is shown:
reboot: must be superuser.
 
Old 05-07-2014, 07:17 AM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
what exact command are you typing to reboot the system?

type the following and copy/past here using code flags:

Code:
$ whoami
$ pwd
after that then type the following:

Code:
$ sudo shutdown -r now
put in the users p/w and the system should shutdown and reboot.

Last edited by lleb; 05-07-2014 at 07:20 AM.
 
Old 05-07-2014, 08:47 AM   #3
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by lleb View Post
what exact command are you typing to reboot the system?

type the following and copy/past here using code flags:

Code:
$ whoami
$ pwd
after that then type the following:

Code:
$ sudo shutdown -r now
put in the users p/w and the system should shutdown and reboot.
/sbin/reboot
I get "Permission denied" to run a file in etc, too.for example: /etc/sudoers
 
Old 05-07-2014, 09:02 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
/etc/sudoers is not an executable, you cannot run it.
/sbin/reboot cannot be run as normal user, you need to execute it as sudo /sbin/reboot.
I hope this helps
 
Old 05-07-2014, 02:40 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,981

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Kind of some issues here.

One is whether or not you have in fact been granted to be a super user or sudo'ed to some other level.

Since we are getting permission denied, we assume it is for the single command that you issued. Is it really a command or is it a script or other that calls to a different command.

A sudo to some command should run all that root can. See what sudo whoami says.

It may be that root has been changed.
 
Old 05-08-2014, 06:55 AM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by massy View Post
/sbin/reboot
I get "Permission denied" to run a file in etc, too.for example: /etc/sudoers
ok, thats fine and dandy, but you didnt follow directions. please copy/paste the info requested above and follow the directions for rebooting the system via sudo.
 
Old 05-10-2014, 02:25 AM   #7
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by lleb View Post
ok, thats fine and dandy, but you didnt follow directions. please copy/paste the info requested above and follow the directions for rebooting the system via sudo.
whoami

check
pwd
/home/check

sudo shutdown -r now


>>> /etc/sudoers: syntax error near line 17 <<<
sudo: parse error in /etc/sudoers near line 17
sudo: no valid sudoers sources found, quitting

,is shown!
The content of my soduers file is in below:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL) ALL
check ALL=ALL(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
 
Old 05-10-2014, 04:55 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you should edit that file using the command visudo. It contains a syntax error at this moment, therefore sudo will not work
 
Old 05-10-2014, 01:13 PM   #9
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by massy View Post
whoami
>>> /etc/sudoers: syntax error near line 17 <<<
sudo: parse error in /etc/sudoers near line 17
sudo: no valid sudoers sources found, quitting
thank you. please use code and quote flags... like so, just remove the extra spacing... [ code ] stuff goes here [ / code ]

will make life much simpler to read.

As pointed out above as root you need to run the command visudo and fix the error on line 17. This is the wonderful thing about Linux. it is telling you exactly were the problem is.

http://www.sudo.ws/sudo/sample.sudoers

that is a good link for how to setup a visudo for sudoers to function properly.

The lines you might be interested in:

Code:
# root and users in group wheel can run anything on any machine as any user
root		ALL = (ALL) ALL
%wheel		ALL = (ALL) ALL
note the use of the code flags for this. much simpler to read.

You might want to add a line in there that looks like this:
Code:
check		ALL = (ALL) ALL
or be more specific as you are just trying to shutdown the system as check

Code:
check		ALL = /sbin/shutdown
this should allow check to execute the shutdown command via sudo.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sudoer for letting a normal user run wireshark jzoudavy Linux - Newbie 2 11-14-2012 10:31 AM
How to remove a user from Sudoer list? tezarin Linux - Newbie 18 03-13-2012 07:43 PM
Add user to sudoer list but cannot use root commands vitalstrike82 Slackware 3 12-31-2008 07:27 AM
How to make a user a sudoer snakeapple Slackware 14 11-20-2008 11:37 AM
sudoer spidna Slackware 2 10-17-2006 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:51 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