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"