Terminal command to bring up shutdown dialog?
You can send loginwindow the kAEShowShutdownDialog Apple event:

osascript -e 'tell application "loginwindow" to «event aevtrsdn»'


The four letter codes for Apple events are listed in AERegistry.h. See this answer for more information.