What if you don’t want your Ubuntu machine to be shutdown or restarted by just any user? Maybe you run a public Internet shop and users frequently shutdown your PC and you want this to stop. Well, this brief tutorial will show you how to make that possible. When this policy is enforced, no regular user will ever shutdown or restart your computer again.

This will also come in handy if you want to connect remotely to your machine anytime without fearing that your system may be shutdown. Without wasting anymore of your time, let’s get going.

Objectives:

  • Prevent regular users from shutting down / restarting your Ubuntu machine
  • Enjoy!

 

To get started, press Ctrl – Alt – T on your keyboard to open Terminal. When it opens, run the commands below to create a shutdown policy file.

sudo gedit /var/lib/polkit-1/localauthority/50-local.d/shutdown.pkla

 

shutdown_oneiric

 

Then copy and paste the lines below into the file and save it.

[shutdown]
Identity=unix-group:admin
Action=org.freedesktop.consolekit.system.stop-multiple-users
ResultAny=no
ResultInactive=no
ResultActive=yes

 

shutdown_oneiric_1

 

Next, run the commands below to create a restart policy file.

sudo gedit /var/lib/polkit-1/localauthority/50-local.d/restart.pkla

 

shutdown_oneiric_2

 

Finally, copy and paste the lines below into the file and save it.

[restart]
Identity=unix-group:admin
Action=org.freedesktop.consolekit.system.restart-multiple-users
ResultAny=no
ResultInactive=no
ResultActive=yes

 

shutdown_oneiric_3

 

Save both files and you’re done. Regular shouldn’t be able to restart or shutdown the PC anymore. To learn how to hide the Log Out screen, hibernation and sleep commands, read this post.