"shutdown -h now" does not function

New to Debian (Or Linux in general)? Ask your questions here!

"shutdown -h now" does not function

Postby kerryhall » 2019-10-21 21:29

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.
kerryhall
 
Posts: 132
Joined: 2008-08-19 11:06

Re: "shutdown -h now" does not function

Postby L_V » 2019-10-21 21:37

Did you try this:
Code: Select all
systemctl poweroff
systemctl poweroff  -f
systemctl poweroff -ff
or
Code: Select all
/sbin/halt
L_V
 
Posts: 1171
Joined: 2007-03-19 09:04

Re: "shutdown -h now" does not function

Postby kerryhall » 2019-10-21 22:44

Code: Select all
systemctl poweroff


Works correctly! Thank you!
kerryhall
 
Posts: 132
Joined: 2008-08-19 11:06

Re: "shutdown -h now" does not function

Postby linuxenthusiast » 2019-11-09 17:14

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
linuxenthusiast
 
Posts: 3
Joined: 2019-11-09 13:29

Re: "shutdown -h now" does not function

Postby Deb-fan » 2019-11-09 18:30

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.
Deb-fan
 
Posts: 445
Joined: 2012-08-14 12:27

Re: "shutdown -h now" does not function

Postby kedaha » 2019-11-09 19:57

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
Mate DE & OSSv4.
FreedomBox in Debian
ispmail
Debian Stable

Words, as is well known, are the great foes of reality. Joseph Conrad.
Kedaha's Conjecture
User avatar
kedaha
 
Posts: 3034
Joined: 2008-05-24 12:26

Re: "shutdown -h now" does not function

Postby L_V » 2019-11-10 14:14

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.
L_V
 
Posts: 1171
Joined: 2007-03-19 09:04

Re: "shutdown -h now" does not function

Postby Deb-fan » 2019-11-10 14:32

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.
Deb-fan
 
Posts: 445
Joined: 2012-08-14 12:27

Re: "shutdown -h now" does not function

Postby L_V » 2019-11-10 14:42

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.
L_V
 
Posts: 1171
Joined: 2007-03-19 09:04

Re: "shutdown -h now" does not function

Postby Deb-fan » 2019-11-10 14:48

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 !!!
Deb-fan
 
Posts: 445
Joined: 2012-08-14 12:27

Re: "shutdown -h now" does not function

Postby L_V » 2019-11-10 14:57

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.
L_V
 
Posts: 1171
Joined: 2007-03-19 09:04

Re: "shutdown -h now" does not function

Postby Deb-fan » 2019-11-10 15:04

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
Deb-fan
 
Posts: 445
Joined: 2012-08-14 12:27

Re: "shutdown -h now" does not function

Postby Deb-fan » 2019-11-10 17:15

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. :/
Deb-fan
 
Posts: 445
Joined: 2012-08-14 12:27

Re: "shutdown -h now" does not function

Postby kedaha » 2019-11-11 10:17

-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.
Mate DE & OSSv4.
FreedomBox in Debian
ispmail
Debian Stable

Words, as is well known, are the great foes of reality. Joseph Conrad.
Kedaha's Conjecture
User avatar
kedaha
 
Posts: 3034
Joined: 2008-05-24 12:26


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 11 guests

fashionable