linux --centos disable reboot command

Disabling the reboot command can be achieved by modifying system files. Specific steps are as follows:

  1. Log in to the server as the root user.

  2. Execute the following command to back up the /sbin/reboot file:

    cp /sbin/reboot /sbin/reboot.bak
    
  3. Open the /sbin/reboot file with a text editor:

    vi /sbin/reboot
    
  4. Add the following at the beginning of the file:

    #!/bin/bash
    echo "Reboot command is disabled. Please contact the system administrator."
    exit 0
    
  5. Save and exit the file.

  6. Modify file permissions to make it executable:

    chmod +x /sbin/reboot
    
  7. Test the disabled effect, execute the reboot command, and the prompt information added above should be output.

Note: Disabling the reboot command may affect the normal operation of the system. It is recommended to disable it only when necessary. If you need to restore the reboot command, you can copy the backup file /sbin/reboot.bak back to /sbin/reboot.

Guess you like

Origin blog.csdn.net/weixin_44634704/article/details/129953821