LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-20-2021, 11:38 AM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Rep: Reputation: 34
Preventing System Shutdown


Greetings, we have a Kubuntu Linux machine which I have set up so several people here can test a Linux system to see if they would like to use Linux for their daily work.

This is working out fine except for the issue that each user is able to shut down the machine at the end of their testing. They aren’t logging off but shutting down the machine.

I find this not to be acceptable but I don’t know of any way to stop this from happening. I would like to restrict these users for being able to shut down the system but I haven’t figured out a resolutions after trying a number of things, nothing works.

Is there a way to define a general user from only logging off and not being able to shut down the system. We are only using one physical terminal for the Linux system at this time. My user id is should be the only super user being able to shut things down.

Any help with this issue is appreciated. Thanks
 
Old 08-20-2021, 11:50 AM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

Have you tried talking to the humans involved? i.e. say "please do not shutdown when you are finished, just logout" when you introduce them to the machine.

You can easily prevent accidental shutdowns by removing the icon from the Application menu (right-click>remove from favourites), and Settings>Workspace>Startup and Shutdown has a checkbox for "Offer shutdown options" which you can deselect.

If there's any other methods, then just login with another user and leave that session in the background - I presume Plasma will prompt in some way if a shutdown is attempted whilst someone else is logged in.

 
1 members found this post helpful.
Old 08-20-2021, 12:43 PM   #3
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by swamprat View Post
Greetings, we have a Kubuntu Linux machine which I have set up so several people here can test a Linux system to see if they would like to use Linux for their daily work.

This is working out fine except for the issue that each user is able to shut down the machine at the end of their testing. They aren’t logging off but shutting down the machine.

I find this not to be acceptable but I don’t know of any way to stop this from happening. I would like to restrict these users for being able to shut down the system but I haven’t figured out a resolutions after trying a number of things, nothing works.

Is there a way to define a general user from only logging off and not being able to shut down the system. We are only using one physical terminal for the Linux system at this time. My user id is should be the only super user being able to shut things down.
This is actually the standard behaviour. Users are by default NOT allowed to shut down the machine. This behaviour has been changed in most distroes though, to allow users to shutdown and reboot. From what I remember, KDE and SSDM adapts to this access, and removes the shutdown and reboot buttons if the user does not have those rights, so it will also look right, not just act right.

However, I can't say that I know how this behaviour is regulated in Kubuntu. It adds Sudo into the mix, but normally this kind of setting should be found in /etc.. Maybe in kubuntu it's in /etc/shutdown.allow. But you should probably also look around in /etc/sudo*

So, just to sum up. You're NOT looking for a way to restrict users. You are looking for a way to reset the behaviour to the standard (only root can reboot/shutdown). This access has been granted to users, and /etc should reflect that somewhere. You might also want to look into /etc/groups and a command "systemctl". In many distroes systemd controls shutdown and reboot and /sbin/shutdown points to /bin/systemctl..

I sadly can't tell you how to change it with systemd, because it tends to make easy things very complicated, and finding out very difficult.

Last edited by zeebra; 08-20-2021 at 01:06 PM.
 
Old 08-20-2021, 02:48 PM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,801

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by swamprat View Post
Greetings, we have a Kubuntu Linux machine which I have set up so several people here can test a Linux system to see if they would like to use Linux for their daily work.

This is working out fine except for the issue that each user is able to shut down the machine at the end of their testing. They aren’t logging off but shutting down the machine.
How are they shutting it down? Via the command line (shutdown -h or halt)? Or by having physical access (using the so-called "Big Red Switch")?

You can prevent them from using the former, the latter is more difficult.

When their accounts are setup, you should be able to remove their rights to the shutdown command. If they're just trying out Linux, at the very least I'd remove any access to root functions through the use of sudo.

HTH...
 
Old 08-22-2021, 11:24 AM   #5
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
Thanks all for your replies. The Sudoers file is a nightmare for a newbi. Can anyone point me to a good example of how to arlter this file preventing various from using certain commands such as shutdown, sleep etc.? I know I have to use a different version of the vi command while editing this file in order not to do something nasty to it. Thanks
 
Old 08-22-2021, 11:58 AM   #6
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by swamprat View Post
Thanks all for your replies. The Sudoers file is a nightmare for a newbi. Can anyone point me to a good example of how to arlter this file preventing various from using certain commands such as shutdown, sleep etc.? I know I have to use a different version of the vi command while editing this file in order not to do something nasty to it. Thanks
This is what happens when I change the shutdown policy for users in a GNU/Linux distro with systemd:

Quote:
INFO: touched file /etc/shutdown.allow
INFO: deleted /usr/bin/shutdown
INFO: deleted /usr/bin/poweroff
INFO: deleted /usr/bin/reboot
INFO: deleted /usr/bin/halt
INFO: Modified system files: /etc/shutdown.allow /usr/bin/shutdown /usr/bin/poweroff /usr/bin/reboot /usr/bin/halt /etc/inittab
Doing this means root can also not use "shutdown" or "reboot" etc. Which means if you want to shut down the computer with root, you could need to use "systemctl shutdown" instead.

If I change it back, it puts back the symbolic links and moves /etc/shutdown.allow to another irrelevant file (backup).
Quote:
INFO: made symbolic link from ../bin/systemctl to /usr/bin/shutdown
/etc/inittab may or may not contain a line like this "ca::ctrlaltdel:/sbin/shutdown -t3 -r now". If you remove this line, you cannot shutdown by pressing ctrl+alt+delete either.

So, if you have an idea what is going on here, and you can VERIFY that those files mentioned above are symbolic links, you could probably solve this situation by deleting those symbolic links and creating an empty file /etc/shutdown.allow.

Or you could just delete those files in any case and hope for the best

Last edited by zeebra; 08-22-2021 at 12:02 PM.
 
1 members found this post helpful.
Old 08-22-2021, 06:34 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by swamprat View Post
The Sudoers file is a nightmare for a newbi. Can anyone point me to a good example of how to arlter this file preventing various from using certain commands such as shutdown, sleep etc.?
Example
 
1 members found this post helpful.
Old 08-22-2021, 08:22 PM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Or try a simple method an SSH banner:

https://www.tecmint.com/protect-ssh-...nner-messages/

Just say, Hey Human.Don't shutdown this machine.
 
Old 08-23-2021, 01:31 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by swamprat View Post
Thanks all for your replies. The Sudoers file is a nightmare for a newbi. Can anyone point me to a good example of how to arlter this file preventing various from using certain commands such as shutdown, sleep etc.? I know I have to use a different version of the vi command while editing this file in order not to do something nasty to it. Thanks
What? Are you sure you tried all the suggestions in post #2 before digging that deep?
 
Old 08-24-2021, 09:13 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
I think that "JJJCR's" solution is probably the most practical: just add a login-banner which tells them ... "Please just log off when you're done – please don't shut down the machine. Thanks."

Hey – when I'm finished using my personal computer each night, I routinely "shut down the machine." It's just what I do and have always done, and I think nothing about it. "Oh ... you don't want me to do that? Okay. Sure. No problem."

Last edited by sundialsvcs; 08-24-2021 at 09:15 AM.
 
Old 08-24-2021, 02:54 PM   #11
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
I think that "JJJCR's" solution is probably the most practical: just add a login-banner which tells them ... "Please just log off when you're done – please don't shut down the machine. Thanks."
This is a Debian-based distro. It should have molly-guard in the repository. I guess it would be a tad more effective than just a login banner. To work for non-SSH sessions, you'll have to configure it via /etc/molly-guard/rc though.

Last edited by shruggy; 08-24-2021 at 02:58 PM.
 
Old 08-24-2021, 11:32 PM   #12
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
Greetings,
First thank you again for your replies, very informative. I was just wondering if couldn't one use 'acls' to stop access to the questioned commands and if so how? Seems that also might work instead of using Sudoers.
 
Old 08-24-2021, 11:40 PM   #13
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by swamprat View Post
First thank you again for your replies, very informative. I was just wondering if couldn't one use 'acls' to stop access to the questioned commands and if so how? Seems that also might work instead of using Sudoers.
No, because they are not real commands in a systemd, they are systemd slaves. Back in the days, you could just remove a user from the shutdown group, easy peacy. If there is a solution to this that is not deleting those symlinks, then it is a systemd internal function. And like most things with systemd it just complicate simple things, and there is a lack of documentation floating around the web.

The real commands are "sysctemctl poweroff" and such things. Ofcourse they could also not even keep the name.
 
Old 08-25-2021, 01:38 AM   #14
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
The question originally asked is not a question of deep system commands, but a question of configuring certain elements of the desktop so that there's no shutdown option, only logout.
This Should(tm) be possible to achieve from within the desktop environment.
I do not use KDE, but it is known for its configurability.
Once again, I think boughtonp had the best answer in post #2.
This search seems to have answers, too.
 
Old 08-25-2021, 02:26 AM   #15
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by ondoho View Post
I do not use KDE, but it is known for its configurability.
It is, but it is a desktop and not responsible for system functions. There are tweaks you can do to make the scenario less likely, but ultimately the KDE logout/shutdown is adapted to what the system allows.
I've given a solution that works, and it doesn't rely on human nature. There is and should be no need to tell anyone anything about not doing this and that, it's fully possible to turn off! If those functions are not allowed on a system level (user shutdown/reboot/etc), then they are also not shown in KDE logout/shutdown options.

Perhaps the system administrator is inexperienced, but at the very least, he should be able to create a folder /root/backup, and move those 4 "files" mention into that folder (he can even include it in his path). That way he can just move them back in case he is insecure. It is not really that dangerous, and the skill level required is not so high. There, I even gave him an easier way to do it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the default powerstate (e.g. S3,S4,S5) for the command 'shutdown -hP' or 'shutdown -hH' or 'shutdown -h' badbetty Slackware 6 11-12-2017 12:18 AM
[SOLVED] Errors preventing shutdown and program execution rjc03001 Linux - Embedded & Single-board computer 2 05-23-2016 08:00 PM
[SOLVED] shutdown works, but /lib/systemd/system/shutdown.target does not. kaz2100 Debian 3 08-06-2014 03:28 AM
driver preventing shutdown/reboot process dbrazeau Linux - Software 1 08-28-2013 07:45 PM
Preventing Shutdown??? ajeetraina Linux - Newbie 6 05-21-2008 07:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration