Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

"shutdown -h now" does not function

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

"shutdown -h now" does not function

#1 Post by kerryhall »

I had a laptop running Debian 9. When shutting down the system, I would just run "shutdown -h now".

I recently upgraded to Debian 10 due to some library requirements for software.

Now however "shutdown -h now" does not function.

When I run the command, the laptop looks like it turns off, but when I hit the power button to turn it back on, it just shows a black screen.

In order to get my laptop started again, I have to take the battery out and put it back in. Then when I press the power button it turns on correctly. When it then boots, it tells me the filesystem wasn't unmounted cleanly so I know the shutdown command isn't actually working.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: "shutdown -h now" does not function

#2 Post by L_V »

Did you try this:

Code: Select all

systemctl poweroff 
systemctl poweroff  -f
systemctl poweroff -ff
or

Code: Select all

/sbin/halt

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: "shutdown -h now" does not function

#3 Post by kerryhall »

Code: Select all

systemctl poweroff
Works correctly! Thank you!

linuxenthusiast
Posts: 3
Joined: 2019-11-09 13:29

Re: "shutdown -h now" does not function

#4 Post by linuxenthusiast »

I am not sure on why it would be related to the shutdown command in particular, maybe someone can explain?
Sites that I find useful :

Ask Ubuntu

It's FOSS

devconnected

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: "shutdown -h now" does not function

#5 Post by Deb-fan »

Yep google can ... search used was "shudown -h now" +debian +doesn't work and the second result was this puppy. Just being a dork and razzing people. :D

Although google does know all if/when asked the right questions. Also just for the record I still use "sudo poweroff" to do this (in Stretch and Buster), you can see it's a symlink to the systemctl junk.

Code: Select all

ls -l /sbin/poweroff
Output of above:

Code: Select all

lrwxrwxrwx 1 root root 14 Aug 20 06:50 /sbin/poweroff -> /bin/systemctl
Same goes for "sudo reboot" too.

Other related stuff, it's cool so why not share.

Someone can also create a .bash_aliases file in their users /home directory and add aliases for this junk. ie:
alias poweroff="sudo /sbin/poweroff" same again for reboot and if you want to be extra special and uber l33t. Create a file in the sudoers.d directory. Read the read me, there's not many naming conventions but you need to follow them if you want them to work and don't want to have to fix sudo. Anyways ... say I create a file named myfile there, so it'd be, /etc/sudoers.d/myfile I actually have one called that there here's the contents.
# Adding some commands I don't need to enter password to run.
yourusernamehere ALL=(ALL) NOPASSWD: /usr/local/bin/ps_mem, /sbin/poweroff, /sbin/reboot, /sbin/iw, /sbin/iwlist, /sbin/iwconfig
The one's am talking about are the /sbin/poweroff and /sbin/reboot. This means I can run these commands w/o need of entering the password. Coupled with the bash alias I have for them, when I type "poweroff" or "reboot" in a terminal, that's what the OS does w/o passwd needed. Could also use them in a menu list item or a keybind/shortcut too.
Most powerful FREE tech-support tool on the planet * HERE. *

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: "shutdown -h now" does not function

#6 Post by kedaha »

Hi,
su - (with a hyphen) to su to root, then shutdown -h now
See Head_on_a_Stick's topic:
forums.debian.net/viewtopic.php?f=16&t=142973
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: "shutdown -h now" does not function

#7 Post by L_V »

Small summary on a problem solved 3 weeks ago. The problem was:
"shutdown -h now" does not function.
When I run the command, the laptop looks like it turns off, but when I hit the power button to turn it back on, it just shows a black screen.
The root cause was very likely '/usr/sbin/shutdown' alias not pointing anymore to the right command.
The only process able to correctly and safely shutdown a laptop is systemd, called by systemctl command.

Code: Select all

ls -l /usr/sbin/shutdown
 /usr/sbin/shutdown -> /bin/systemctl
You have the choice among systemctl halt or poweroff or reboot.

Code: Select all

halt        :  Shut down and halt the system
poweroff : Shut down and power-off the system
reboot    :  Shut down and reboot the system
Do you need a root password or any other password to shutdown a laptop as user ?
Definitively and hopefully not !!
Imagine you have to provide a root password to all laptop users you have installed Debian on..... Would you really do that ????

The role of any Display Manager (like SDMM or any other) is to provide the right permissions to users for commands which should not require any "root" password.

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: "shutdown -h now" does not function

#8 Post by Deb-fan »

It's all easily enough dealt with, all well documented with more clear examples around than someone could need. It's gnu/Nix as such can be 40 diff ways to do whatever(all can even be approved and all work well too.) In my case I don't use a display manager, don't use a DE either (Openbox) nor xfce power-manager plugin thingy etc etc etc. All of which and many other ways no doubt would enable user to poweroff/reboot w/o password. The method outlined above is just the way I've come to prefer doing it, that's the bottom-line a preference and yep, for obvious reason "sudo poweroff" no alias ... or as shown above alias poweroff (no passwd or sudo appended required) makes much more sense to me than typing "shutdown -h now". Plus of course is totally approved and assume that backwards compatibility will remain included in systemd indefinitely.

If/when it ever does change, would take all of 5mins or less to adapt sudoers.d file and .bash_aliases to be whatever an end-user prefers to do those same things shutdown/reboot/suspend or hibernate a system. :)
Last edited by Deb-fan on 2019-11-10 14:46, edited 1 time in total.
Most powerful FREE tech-support tool on the planet * HERE. *

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: "shutdown -h now" does not function

#9 Post by L_V »

Deb-fan wrote:would take all of 5mins or less to adapt sudoers.d file and .bash_aliases
Always very long phrasing..., but would you take less than 30 sec to understand that poweroff process is not managed by any "sudo", but by systemctl through policykit.
https://wiki.debian.org/UserShutdown
Last edited by L_V on 2019-11-11 07:35, edited 2 times in total.

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: "shutdown -h now" does not function

#10 Post by Deb-fan »

Lol and if you'd take a sec to read the first couple lines in my first post, yep ... already noted it's linked to systemctl. Which is an intentional backwards compatibility thing folks have implemented because many folks use those cmds to poweroff and reboot. :D

Andddddddddd P L O N K !!!
Most powerful FREE tech-support tool on the planet * HERE. *

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: "shutdown -h now" does not function

#11 Post by L_V »

Deb-fan wrote:Lol and if you'd take a sec to read the first couple lines in my first post
Simply impossible in a sec. Try it yourself. Much much too verbose and usually really difficult to catch your message or "problems" in all threads.

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: "shutdown -h now" does not function

#12 Post by Deb-fan »

Ah no worries, I don't ever ask for help, out of 1,000's of posts, across 5-7 forums in the past 8+ yrs, maybe once and didn't get anything useful, as I'd already researched my issue exhaustively before even asking, so people provided google links, I'd already read/tried etc. As for TL:DR = too long didn't/don't read, sheesh peeps, DON'T READ MY POSTS !!! Problem easily solved. Scroll or plonk me dang ! :D
Note2self: Must research a new and improved PLONK'ing method, javascript or summin. As otherwise desired plonks aren't in effect if someone visits a site and isn't signed into their acct. Lmao ... ah it's not that serious but definitely have come to believe liberal use of forums plonk-feature is critical. Never EVER used to do the plonk thing but that's changed radically. Ideally said plonking should detect threads started by a plonkee and remove them so they're not even seen. :D
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: "shutdown -h now" does not function

#13 Post by Deb-fan »

Doubles back to un-PLONK L_V ... Know english isn't your first language and I do tend to have much to say about gnu/Nix and tech. Though this is a forum meant for discussing that topic. Not very exciting when people post 2 lines about whatever. This forum is mostly on life support as it is. Would think folks would welcome some convo, shrugs. Also yep, have a certain babbling all over the place posting style but that's my way and won't change it to conform to what someone else thinks it should be.

Mentioned folks are absolutely free to not read my posts, scroll and/or slap me on ignore. Anyway group hug !? :) Plus no worries, will soon burn myself out on gnu/nix forum'ing and go dormant again regardless. Would join the Slackware and Gentoo + possibly the PClinuxOS forums, there's much about them (their communities)feel have mucho potential but am not giving up Debian, so due to differences between these would make meaningful interaction with the folks there somewhat tough me thinks. :/
Most powerful FREE tech-support tool on the planet * HERE. *

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: "shutdown -h now" does not function

#14 Post by kedaha »

-h
Equivalent to --poweroff, unless --halt is specified.
I often use the shutdown -h now" on my desktop system. I assume it also works on laptops too but it may malfunction here & there.

Code: Select all

user@debian:~$ shutdown -h now
bash: shutdown: command not found
without the hyphen it doesn't work:

Code: Select all

user@debian:~$ su
Password: 
root@debian:/home/user# shutdown -h now
bash: shutdown: command not found
root@debian:/home/user# exit
exit
but it does work after the su -ing to root the hyphen - :

Code: Select all

user@debian:~$ su -
Password: 
root@debian:~# shutdown -h now
& the command functions.
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

Post Reply