How to disable shutdown and reboot commands in Linux

How to disable shutdown and reboot commands in Linux

A Linux system administrator needs to know some Linux tricks. In this article, you will learn how to disable shutdown and reboot commands in Linux.

To power down a Linux system, you need to use the shutdown command schedules a time. While Linux distros such as Ubuntu, Linux Mint, Mandriva, make it possible to reboot/halt/shutdown the system as a normal user, by default. It is not an ideal setting, especially on servers. Above all, it must be something to worry about especially for a system administrator.

To fix this issue, we will show how to disable shutdown and reboot commands for normal users in Linux.


Buy Linux Virtual Private Server

Recommended Article: DNF command on CentOS 8

How to disable shutdown and reboot commands in Linux

Let’s review one of the easiest ways of shutdown and reboot commands using the /etc/sudoers file.

vi /etc/sudoers  

Add these lines to the Command Aliases section.

Cmnd_Alias     SHUTDOWN = /sbin/shutdown,/sbin/reboot,/sbin/halt,/sbin/poweroff    User privilege specification  eldernode   ALL=(ALL:ALL) ALL, !SHUTDOWN    Allow members of group sudo to execute any command  %developers  ALL=(ALL:ALL) ALL,  !SHUTDOWN

Try to execute shutdown and reboot commands as a normal user.

chmod o-x /sbin/shutdown  chmod o-x /sbin/reboot

Please Note: Under systemd, these file(/sbin/shutdown, /sbin/reboot, /sbin/halt, /sbin/poweroff) are only symbolic links to /bin/systemctl:

ls -l /sbin/shutdown  ls -l /sbin/reboot  ls -l /sbin/halt  ls -l /sbin/poweroff

In conclusion, you can remove execution permissions as explained above, to prevent other users from running these commands. Since is not effective under systems. , you can remove execution permissions on /bin/systemctl meaning all other users except root will only run systemctl.

chmod  o-x /bin/systemctl


Good job! You finished the tutorial and reached to the purpose of our guide. Share with us if you know any other way of doing this, in the comments.

Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.


You can find more related articles in:

Enable Root Login via SSH in Ubuntu 20.04



How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

    Leave Your Comment

    Your email address will not be published.

    We are by your side every step of the way

    Think about developing your online business; We will protect it compassionately

    We are by your side every step of the way


    7 days a week, 24 hours a day