Is it possible for a normal user to execute reboot without having the root password?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,673
Rep:
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.
^ 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.