14.04 and above
Falconer's answer helped me very much, but lightdm changed for Ubuntu Trusty 14.04. There is no longer a /etc/lightdm/lightdm.conf
file on my system. lightdm has now gone the "Debian way" and had its configuration broken up into a conf.d directory. You now need to create the following file:
/etc/lightdm/lightdm.conf.d/80-display-setup.conf
[SeatDefaults]
display-setup-script=xrandr -o right
As suggested in Electric Head's answer, the xrandr command can go right in this file, no need to create a separate script.
If you want a xrandr command that deals with multiple monitors, you can use arandr
to generate it for you. My xrandr
command actually ends up being:
xrandr --output DVI-1 --mode 1920x1080 --pos 1080x0 --rotate left --output DVI-0 --mode 1920x1080 --pos 0x0 --rotate right
To get that I used the following commands:
sudo apt-get install arandr
arandr
- Use the GUI to configure your monitors like you want them:

- Use "Layout" -> "Save As" to save it to a file that contains your monitor configuration command.
With this in place, my monitors are properly rotated when I log in as well, so there is no need to do additional configuration in Gnome, XFCE, or KDE. The only other place that I need to configure monitor rotation is in virtual framebuffer terminals, as explained in How do I rotate my display when not using an X Server?