how to shutdown a linux machine, including the root password, in 1 line?

Solution 1:

Yes, sudo has a '-S' a switch that allows it to read in the sudo password from stdin. All you have to do is echo your root password - so for your instance it would look like this (replace [PASSWORD] with your root password)

history -d $((HISTCMD-1)) && echo '[PASSWORD]' | sudo -S shutdown now