I'm trying to reboot my Debian 10 server but all I get is "Command not found. I've tired
shutdown
reboot
restart
poweroffbut nothing works. I found this thread but when I try to run any of this with sudo I get bash: sudo: command not found.
Atm I'm logged in as root so I should have the privileges to restart the machine.\n
Any Ideas?
6 Answers
The trick on how to fix this inconvenience is to explicitly tell the su to set environment variable as if the user logs in directly. This is can be done by the use of - switch.
$ su -
Debian 10 has now fully switched to Systemd which means that the traditional commands to halt or reboot a system like 'shutdown -h now' or 'reboot' will not work anymore
Starting with Debian 10, you should use the commands systemctl poweroff or systemctl reboot.
Edit: It appears the above source was partially incorrect, you can still log in as root (see answer by Eugene) to run the old commands. If you don't want to log in as root, use systemctl.
As 'root' -> 'systemctl poweroff' or 'systemctl reboot'
3As 'root' -> Edit /root/.bashrc
Add to the end of the file:
alias reboot='systemctl reboot'
alias poweroff='systemctl poweroff'Save the file and start session as root again.
1Try:
nano /bin/reboot
add line: systemctl reboot
exit and save
chmod to your preffered execution level
I'm sure there is a more elegant way to fix this but I am going to have a hard time remembering that only debian 10 requires a special reboot command. This works for me as long as i'm in su first.
Use /sbin/shutdown [OPTIONS...] [TIME] [WALLMSG] :)