I want to grant 'shutdown' previlege to a non-root user to do directly from console
Linux - GeneralThis 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
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.
I want to grant 'shutdown' previlege to a non-root user to do directly from console
I want to grant 'shutdown' privilege to a non-root user to to shutdown directly from the linux 2.1 console. I can able to do it via network login using 'sudo'
or you can put in sudoers file the option without password.
after that, you call shutdown.
Open a root terminal and type `visudo'. This will open the config file for sudo.
I'm getting the error after changing the permission to 755
Here are my steps:
#chmod 755 shutdown
#ls -la shut*
-rwxr-xr-x 1 root root 15488 Jun 26 2003 shutdown
# su - oracle
$ /sbin/shutdown
shutdown: you must be root to do that!
$ /sbin/shutdown -a
shutdown: you must be root to do that!
I'm getting the error after changing the permission to 755
Here are my steps:
#chmod 755 shutdown
#ls -la shut*
-rwxr-xr-x 1 root root 15488 Jun 26 2003 shutdown
# su - oracle
$ /sbin/shutdown
shutdown: you must be root to do that!
$ /sbin/shutdown -a
shutdown: you must be root to do that!
This is exactly why you should just setup sudo instead, there's more involved than just changing the permissions of the command.
I, too, like the sudo approach because you can grant access to specific commands to only certain users, and can even specify the exact command line that they can run. However, chmod 4755 works. The 4 sets the set-user-id on execution bit. Then, since this command is owned by root, when a non-root user runs the shutdown command, they run it with the same identity as root. On a multiple user system this would be bad since anyone could now shut the system down, so this is definitely a case where sudo is better.
The following steps did the trick:
-------------------------------------
1. Create shutdown.allow file under /etc
2. Add the non-root user who wants to perform shutdown in that file
3. Login in as that user
4. $/sbin/shutdown -a -h now
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.