Page 1 of 1

shutdown properly via bash

Posted: Fri Feb 01, 2013 8:48 am
by Otyugh
Hey,
I wonder how i could shutdown normally a systemn with a bash command.
The one I used actually is "sudo shutdown -h now".

But I also noticied it wasn't a normal shutdown. Actually when I shut my pc through mint I have to wait a few seconds to see some service being stoped. With shutdown command I feel like I'm doing it "barbarian way".

Re: shutdown properly via bash

Posted: Fri Feb 01, 2013 4:08 pm
by SiKing

Code: Select all

sudo init 0

Re: shutdown properly via bash

Posted: Fri Feb 01, 2013 7:51 pm
by Otyugh
Hey,
I used your command and I don't quite see the difference with the shutdown. It don't display any "step" before shuting down. It's strange to me.

Re: shutdown properly via bash

Posted: Sat Feb 02, 2013 11:13 am
by kwisher
How about "sudo poweroff" ?

Re: shutdown properly via bash

Posted: Mon Feb 04, 2013 3:27 pm
by Otyugh
The same way, I do not see any log message saying somethinh like "stoping the running programs in less than 2 seconds" and stuffs.
I really don't know if the commands you gave to me is doing this and just doing it silently, or if they are all the same "brutal shut down" as if i forced to quit every program. :(

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 4:35 am
by Jamesc359
shutdown -h now is a perfectly safe and valid method to shutdown a system. There's nothing brutal about it. :)

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 2:09 pm
by Otyugh
My very big point about it, it's that it have to be done as root. Secondly it does not stop to shutdown if any "gedit text wasn't saved yet", it just quit everything. Isn't that brutal ?
I mean, the difference between "i ask you to close" and "I just kill you, because i'm the system, kid".

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 2:43 pm
by bjornmu
There is no way for the system to know which running user processes need to be told to "close" in a controlled manner, and how to do so. Nor can it know in which order to shut them down or how long to wait. All it can do is to send the processes a SIGTERM signal but I don't know if it actually does? Then it's each program's responsibility to do some sensible actions but it's limited what they can do.

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 3:37 pm
by SiKing
bjornmu, I suspect you are expecting too much here.

As was already mentioned, shutdown is considered perfectly "safe". If you read 'man shutdown' you will notice the following:
shutdown arranges for the system to be brought down in a safe way.
...
Once TIME has elapsed, shutdown sends a request to the init(8) daemon to bring the system down into the appropriate runlevel.
You can further read about 'man 8 init' and 'man 7 runlevel' to find out all the gory details. These systems bring down any running system processes in the correct order. Any user processes are sent a signal to shutdown, however applications often ignore this. You can submit defect against each application if you'd like. However, the general assumption is that the user will take care to properly save all their work, since the system has no way of knowing if the user actually wants to save any changes they made. This can lead to a debate of epic proportions...

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 4:02 pm
by bjornmu
I'm not expecting much, my point was that the OP may be expecting too much.

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 4:09 pm
by SiKing
bjornmu wrote:I'm not expecting much, my point was that the OP may be expecting too much.
:oops: sorry, copy-paste mistake.

Re: shutdown properly via bash

Posted: Tue Feb 05, 2013 4:20 pm
by DrHu
The system way is to force off all programs and then power off, so that is the barbarian way
--what this is really is an admin control of the overall system, and is fairly obviously the normally expected behavior, no different than a windows or Apple OS shutdown
  • If it was a server system, rather than a desktop OS, then the shutdown operation would not be available to a normal user, what the windows OS names as a limited account..
    --a non-admin or root user..
  • The normal user or in the case of Ubuntu/Mint an admin (sudo) group user can do pretty much what they want on the system, and on the command line (terminal) can use the shutdown command
    --a new user, could be excluded from that option, via the /etc/sudoers file if the admin of the desktop wanted to do so, but that probably doesn't really make much sense with a desktop, unless you intended to operate in a kiosk-style mode: more admin controls, less user interactions
A user should normally expect in any multiuser system to log-off, and if they were not an administrator of the system to either not be able to shutdown (via the desktop) or be allowed to do do..