Linux allows common users to execute shutdown

Source: Internet
Author: User

Take Fedora5 as an example. It is similar to other types such as Ubuntu.
The current user name is test, which is a common user. When you enter the shutdown command, the message must be superuser is displayed. The superuser is required to execute this command. The procedure is as follows:
[Test @ localhost ~] $ Halt
Halt: must be superuser.
After testing, I found that you can use the umask command to set it as follows:
[Test @ localhost ~] $ Su-
Password:
[Root @ localhost ~] # Which halt
/Sbin/halt
[Root @ localhost ~] # Ll/sbin/halt
-Rwxr-xr-x 1 root 12584 Feb 14 2006/sbin/halt
[Root @ localhost ~] # Chmod 4755/sbin/halt
[Root @ localhost ~] # Ll/sbin/halt
-Rwsr-xr-x 1 root 12584 Feb 14 2006/sbin/halt
[Root @ localhost ~] # Exit
[Test @ localhost ~] $ Halt

Broadcast message from root (pts/1) (Thu May 19 12:25:35 2011 ):
The system is going down for system halt NOW!
After comparison, you will find that when a common user executes the halt command, the system reports that "super user is required to execute", which means you can find me, but you do not have the permission to execute me.
The shutdown command is different. When a common user executes it, the system returns the following message: "No relevant command is found." This means that you cannot find me, and of course you do not have the permission to execute me.
[Test @ localhost ~] $ Shutdown
-Bash: shutdown: command not found
How can we solve this problem? Haha.
[Test @ localhost ~] $ Su-
Password:
[Root @ localhost ~] # Chmod 0755/sbin/shutdown
[Root @ localhost ~] # Which shutdown
/Sbin/shutdown
[Root @ localhost ~] # Ll/sbin/shutdown
-Rwxr-xr-x 1 root 21872 Feb 14 2006/sbin/shutdown
[Root @ localhost ~] # Chmod 4755/sbin/shutdown
[Root @ localhost ~] # Ll/sbin/shutdown
-Rwsr-xr-x 1 root 21872 Feb 14 2006/sbin/shutdown
After the modification is complete, try to execute the following:
[Test @ localhost ~] $ Shutdown-h now
-Bash: shutdown: command not found
Still not good !?
You can run the echo $ PATH command to find whether the PATH/sbin exists. Therefore, if you run the shutdown command, you can directly enter the absolute PATH. As follows:
[Test @ localhost ~] $/Sbin/shutdown-h now
Broadcast message from root (pts/1) (Thu May 19 12:56:09 2011 ):
The system is going down for system halt NOW!
[End]
Author: "Daily Yunhui"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.