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.
- Prevent regular users from shutting down / restarting your Ubuntu machine
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
Then copy and paste the lines below into the file and save it.[shutdown]Identity=unix-group:adminAction=org.freedesktop.consolekit.system.stop-multiple-usersResultAny=noResultInactive=noResultActive=yes
Next, run the commands below to create a restart policy file.sudo gedit /var/lib/polkit-1/localauthority/50-local.d/restart.pkla
Finally, copy and paste the lines below into the file and save it.[restart]Identity=unix-group:adminAction=org.freedesktop.consolekit.system.restart-multiple-usersResultAny=noResultInactive=noResultActive=yes
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.