I've noticed that the command 'sudo poweroff' successfully shuts down my system, but when I try to use just 'poweroff' as root, it fails because it can't find the command. I understand that 'sudo poweroff' is essentially the same as 'sudo systemctl poweroff', but why doesn't the simple 'poweroff' command work when I'm already logged in as root?
2 Answers
If you switched to root using `su`, try using `su -` instead. When you use `su`, you inherit your regular user's `$PATH`, which usually doesn't include directories like `/usr/sbin`, where `poweroff` is located. Using `su -` switches to a proper root environment and enhances your `$PATH`, allowing the command to work. Also, it might depend on the Linux distribution you're using; being on Debian could influence this.
Great tip! I was always confused about `su` and `su -`. Now I see how it impacts the path!
You could try using the `shutdown` command instead. It might be more compatible across different distros. However, I've noticed that on Arch, you don’t have to prepend `sudo` to `shutdown` like you often do on Debian. Seems like permission settings differ from one distro to another!
Exactly! I find using `shutdown` works great on Arch, but I'm having trouble with it on Debian. Your explanation about paths helps a lot!

That's an interesting point! On my Ubuntu setup, `poweroff` works seamlessly, but I've had to use `sudo poweroff` on Arch. It seems like the path configuration varies.