poweroff is a symlink provided by systemd-sysvcompat that does nothing more than execute systemctl, which is exactly the same as calling systemctl poweroff. This also goes for the other power management binaries.
It is advised because the direct commands like poweroff are only available for compatibility reasons. Red Hat wants to migrate its users away from those, so that they don't need to provide those forever. You also can't know whether Arch will keep shipping those, but I think it's safe to say that they'll be around for a while.
This is dangerous, if someone gets access to your $HOME they can replace the systemctl poweroff with literally anything else and you'd blindly type out your root password into it, easiest privilege escalation exploit I've ever seen.
I'm assuming it does ask for the root password though since you don't usually need it for personal computers.
I'm not sure the alias changes much about that attack vector. With access to $HOME you can prepend things to $PATH, so you can inject a script called pacman (for example) that checks if it has root and if so does Bad Things, and then in either case forwards to the real one.
This attack vector will be present for every single alias that you use in your shell rc files. Does that mean we should just stop using aliases? No! Just don't allow randos to access your home directory if you're so worried about malicious activities.
/u/semeionic: If you have polkit installed and running, then you don't even need sudo in your alias. systemctl poweroff should work just fine (EDIT: Doesn't work if you're not an admin or if another user is logged onto the system).
So I use i3wm with Arch Linux. I had a key binding with 'systemctl poweroff' and a button on polybar with 'shutdown now'. I used to use the keybinding but everytime I used to boot up, the internet would go away after a few minutes. Then after using 'shutdown now', it doesn't. I have had uptime of more than a few days now with no internet downtime.
30 comments
poweroffis a symlink provided bysystemd-sysvcompatthat does nothing more than executesystemctl, which is exactly the same as callingsystemctl poweroff. This also goes for the other power management binaries.Deleted before we saved it.
It is advised because the direct commands like
poweroffare only available for compatibility reasons. Red Hat wants to migrate its users away from those, so that they don't need to provide those forever. You also can't know whether Arch will keep shipping those, but I think it's safe to say that they'll be around for a while.Does that answer your question?
Deleted before we saved it.
When
systemctlgets executed via that symlink it recognizes that the original link is namedpoweroffand performs poweroff.I have no idea what is the best way, but i use this alias:
alias fim='sync && sudo systemctl poweroff'I am using it have more than 5 years, without any problem.
This is dangerous, if someone gets access to your $HOME they can replace the
systemctl poweroffwith literally anything else and you'd blindly type out your root password into it, easiest privilege escalation exploit I've ever seen.I'm assuming it does ask for the root password though since you don't usually need it for personal computers.
I'm not sure the alias changes much about that attack vector. With access to $HOME you can prepend things to $PATH, so you can inject a script called
pacman(for example) that checks if it has root and if so does Bad Things, and then in either case forwards to the real one.This attack vector will be present for every single alias that you use in your shell rc files. Does that mean we should just stop using aliases? No! Just don't allow randos to access your home directory if you're so worried about malicious activities.
/u/semeionic: If you have polkit installed and running, then you don't even need sudo in your alias.
systemctl poweroffshould work just fine (EDIT: Doesn't work if you're not an admin or if another user is logged onto the system).I have
alias pacsyu='sudo pacman -Syu'. Is that risky too?Hum... Never thought of that.
I guess
alias docker='sudo docker'is not good either.But, what if I was putting my special
sudoaliases in a file owned by root. It should be safe, right ?What the egg? Systemd is responsible for powering off my computer too? It really has its claws and flaws in everything these days.
inithas more or less always been in control of shutdown/reboot, see 1, so this may be the least controversial function systemd could have taken overthe only thing in that domain that systemd took on that wasn't in SysV is control of suspension/hibernation, in lieu of
pm-utilset al.Disclaimer: Personal experience
So I use i3wm with Arch Linux. I had a key binding with 'systemctl poweroff' and a button on polybar with 'shutdown now'. I used to use the keybinding but everytime I used to boot up, the internet would go away after a few minutes. Then after using 'shutdown now', it doesn't. I have had uptime of more than a few days now with no internet downtime.
https://www.reddit.com/r/archlinux/comments/cylrvs/the_internet_seems_to_go_down_after_sometime/
Deleted before we saved it.
This is what confuses me. Also, systemctl suspend never seems to work. My laptop gets overheated and it freezes on trying to resume from it.
Both invoke the same thing under a systemd system.