LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-02-2016, 11:45 AM   #1
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Rep: Reputation: Disabled
Is it possible for a normal user to execute reboot without having the root password?


I want to be able to give normal users the ability to reboot the machine, if a normal user tries to execute a reboot it will ask for the root password, which I don't want them to have.

Is it somehow possible to set up exemptions for some commands to not require root access?

Many thanks.
 
Old 09-02-2016, 11:59 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,611
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
Quote:
Originally Posted by Entropy1024 View Post
I want to be able to give normal users the ability to reboot the machine, if a normal user tries to execute a reboot it will ask for the root password, which I don't want them to have.

Is it somehow possible to set up exemptions for some commands to not require root access?

Many thanks.
Yes, of course. For this kind of thing you use sudo. If it isn't already installed on your machine, just install it in the usual way.

sudo comes with a configuration file called /etc/sudoers. This allows you to give very fine-grained rights to users. You can allow some commands such as shutdown and reboot to be executed by a particular user without providing full root access. This can be done with a password (their own password, not the root one) or without. In fact sudo has a built in timer so that once a user password has been given, it will hold good for subsequent sudo commands within a small time span. All the user has to do is preface the command with the word "sudo".

One caveat. You must do all edits of sudoers with the visudo command. Never use an editor directly on this file or you could really screw up your system.
 
2 members found this post helpful.
Old 09-02-2016, 12:00 PM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Yes. This is the exact purpose of sudo. It allows you to grant users the ability to run certain programs as if they were the root user. They only have to know their own password and only have access to the specific commands you grant them.

https://www.linux.com/blog/how-use-s...x-introduction
 
1 members found this post helpful.
Old 09-02-2016, 12:05 PM   #4
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
posted in error

Last edited by Entropy1024; 09-03-2016 at 03:33 AM. Reason: posted in error
 
Old 09-02-2016, 12:56 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Sudo: you're doing it wrong - PDF @ 171 pages.

Good stuff, Maynard.
 
2 members found this post helpful.
Old 09-02-2016, 02:16 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Entropy1024 View Post
Is it possible to detect that a file has been opened?

If for example; If I had a 'readme.txt' file on the desktop, can I get the system to log when a user opens the document?
what's that got to do with the original question?
anyhow, try
Code:
lsof
 
Old 09-02-2016, 02:27 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,997

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
I push the power button one time and it reboots usually. (may not be as asked)

Last edited by jefro; 09-02-2016 at 08:51 PM.
 
Old 09-02-2016, 02:35 PM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ doesn't that require the underlying command (e.g. systemctl reboot) to have superuser privileges granted?
 
Old 09-02-2016, 03:28 PM   #9
UseTheSourceLuke
LQ Newbie
 
Registered: Aug 2016
Posts: 2

Rep: Reputation: Disabled
deleted

Last edited by UseTheSourceLuke; 09-02-2016 at 07:00 PM.
 
Old 09-05-2016, 06:25 AM   #10
dumb_programmer
LQ Newbie
 
Registered: Sep 2016
Location: India
Distribution: Ubuntu 16.04 , Windows 7 ultimate
Posts: 6

Rep: Reputation: Disabled
Is it possible for a normal user to execute reboot without having the root password?

you might want to try init 6.
works for me!
 
Old 09-05-2016, 06:30 AM   #11
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
^ doesn't that require the underlying command (e.g. systemctl reboot) to have superuser privileges granted?
In my boxes it generates ACPI event and results in shutdown.
 
Old 09-05-2016, 07:59 AM   #12
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,673

Rep: Reputation: 487Reputation: 487Reputation: 487Reputation: 487Reputation: 487
Quote:
I want to be able to give normal users the ability to reboot the machine
If this is a multiuser machine, i.e. a machine with more than one user using it concurrently (probably a server) I'd have to say that this would be a bad idea as any one user could effectively screw up the other users work by shutting it down.

OK, so you're probably talking about a shared desktop but I just felt I just had to add my to clarify.

Play Bonny!

 
Old 09-05-2016, 11:11 AM   #13
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
On the use of visudo, if you aren't familiar with vi, use the command
EDITOR=nano visudo
(or whatever editor you like).
 
Old 09-05-2016, 04:24 PM   #14
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Quote:
Originally Posted by ondoho View Post
^ doesn't that require the underlying command (e.g. systemctl reboot) to have superuser privileges granted?
The power button triggers an acpi event and if you have acpid running with an event handler for the power button it will reboot / power off. The daemon is already running as root so you do not need to authenticate. YMMV as systemd opted to change the syntax of shutdown and many of those "handlers" didn't get the memo.
 
Old 09-05-2016, 06:59 PM   #15
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,997

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Then we get into normal command shutdown and did all the databases get closed first and such.

I think the first reply would be correct about sudo for most folks but not all.
 
  


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
How to login root from normal user without password yogeshjadhav96 Linux - Newbie 6 08-27-2015 02:33 AM
[SOLVED] Give normal user root privileges and using same password. linustalman Linux - Security 7 08-11-2014 08:59 PM
Allow Normal User to Change Root Account Password Digistras Linux - Newbie 10 07-29-2014 10:27 AM
Root execute command as a normal user carlosjf Linux - Newbie 5 04-01-2011 06:41 PM
How could normal user obtain root password or change root password ckamheng Debian 18 02-18-2009 10:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:07 AM.

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