1

Is there a way to check if you have permission to reboot without actually running sudo reboot? I don't want to try it, because if I have permission, then it will just reboot the server and I don't want this to happen. Just need to check if I have the permission to reboot.

I don't have read permission to /etc/sudoers as I'm not root. Any solution other than trying the command?

  • 3
    Consider also sudo -l to list the commands available to you. – Jeff Schaller Nov 1 '17 at 20:07
  • @JeffSchaller Thanks Jeff. This is a very useful command. – rana Nov 1 '17 at 20:14
3

Only write the wtmp record:

reboot -w

-w: only write a wtmp reboot record and exit.

2

To expand on my earlier comment, you can find out if you have sudo permission to run /sbin/reboot by asking sudo to list your allowed commands with sudo -l.

To go over some common possibilities:

  1. You have been granted "full" sudo access:

    User you may run the following commands on machine:

    (ALL : ALL) ALL

In this case, you'll be able to run /sbin/reboot with any or no parameters.

  1. You have been granted access to the /sbin/reboot command directly:

    User you may run the following commands on machine:

    (root) /sbin/reboot

In this case, you'll be able to run /sbin/reboot with any or no parameters.

  1. A variation on the above:

    User you may run the following commands on machine:

    (root) NOPASSWD: /sbin/reboot

In this case, you'll be able to run /sbin/reboot without first being prompted for your password. Without the NOPASSWD flag, you'll be prompted in each separate tty for your own password, which is then cached for a timeout amount of time, defaulting to 15 minutes.

  1. Specific commands listed, none of which are /sbin/reboot:

    User you may run the following commands on machine:

    (root) /bin/ls /bin/grep

In this case, you've been granted a specific list of commands, none of which are /sbin/reboot; if you attempt to run sudo /sbin/reboot, after possibly being prompted for your password, you'll receive the message:

Sorry, user you is not allowed to execute '/sbin/reboot' as root on machine.fqdn.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.