LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   User shutdown - 'cp -i -p shutdown /usr/sbin/shutdown2 - why does this not work, can? (https://www.linuxquestions.org/questions/linux-desktop-74/user-shutdown-cp-i-p-shutdown-usr-sbin-shutdown2-why-does-this-not-work-can-712889/)

mitchellray 03-19-2009 01:31 PM

User shutdown - 'cp -i -p shutdown /usr/sbin/shutdown2 - why does this not work, can?
 
Hello,
Why can not 'shutdown' script file be copied to path of ordinary user and then called?

After I copied to new file /usr/sbin/shutdown2 (which I thought was in the ordinary users' path), I still could not shutdown. Why can't user call for that executable file?

Interestingly, as root, I was able to call 'shutdown2 -hP now' and affect a power off.

ls -l shutdown2
-rwxr-xr-x 1 root root 16864 2008-04-02 19:40 shutdown2

So why is the output

$ shutdown2
-bash: shutdown2: command not found

It seems that users and root have the same login shell, yet the command is not found.

I have seen that others have solved using sudoer, however, other os seem to have it already available for users to call 'shutdown' without invoking 'sudo'.
M

TB0ne 03-19-2009 04:58 PM

Quote:

Originally Posted by mitchellray (Post 3481046)
Hello,
Why can not 'shutdown' script file be copied to path of ordinary user and then called?

After I copied to new file /usr/sbin/shutdown2 (which I thought was in the ordinary users' path), I still could not shutdown. Why can't user call for that executable file?

Interestingly, as root, I was able to call 'shutdown2 -hP now' and affect a power off.

ls -l shutdown2
-rwxr-xr-x 1 root root 16864 2008-04-02 19:40 shutdown2

So why is the output

$ shutdown2
-bash: shutdown2: command not found

It seems that users and root have the same login shell, yet the command is not found.

I have seen that others have solved using sudoer, however, other os seem to have it already available for users to call 'shutdown' without invoking 'sudo'.
M

Don't know what other OS you are referring to, but every Linux/unix system I've worked with, needs root privileges to shut the system down. It's a security feature...shutdown, along with alot of other programs, need escalated privs to run. Putting a 'regular' user ID in sudoers, then calling it with "sudo <command name>", let's you stay in a 'regular' account (so you can't damage things accidently), and only escalate when needed.

What shell root and users run don't make a difference..it's the privilege level they run it AS that makes the difference.

anomie 03-19-2009 05:02 PM

Quote:

Originally Posted by mitchellray
After I copied to new file /usr/sbin/shutdown2 (which I thought was in the ordinary users' path), I still could not shutdown. Why can't user call for that executable file?

You've got two different issues. The first is privileges, as already mentioned. The second is PATH.

Check the results of $ echo $PATH as root and as a regular user, and compare.

mitchellray 03-20-2009 02:34 PM

FC5 and Fedora10 users can shutdown - How?
 
Thank you TBOne and anomie.

I have previously loaded FC5, Fedora10 and Ubuntu and all three allowed me to shutdown and poweroff without additional permissions granted by root.
This is a desktop computer AMD K7.
I am yet to fully understand the permission issue since I thought that the users were able to read and execute the command as above.
I also tried putting 'shutdown3' in '/usr/bin' just for trial and error. My error.
M

TB0ne 03-20-2009 09:31 PM

Quote:

Originally Posted by mitchellray (Post 3482434)
Thank you TBOne and anomie.

I have previously loaded FC5, Fedora10 and Ubuntu and all three allowed me to shutdown and poweroff without additional permissions granted by root.
This is a desktop computer AMD K7.
I am yet to fully understand the permission issue since I thought that the users were able to read and execute the command as above.
I also tried putting 'shutdown3' in '/usr/bin' just for trial and error. My error.
M

If you set the workstations up to allow shutdown from the console, and allow any user to run it, it WILL shut down as a 'regular' user. Ubuntu is geared towards non-power users, so shutdown will work fine.

From the command line, though, things are different.


All times are GMT -5. The time now is 03:38 AM.