This post was originally published on go2linux.org on February 9, 2008. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.
Introduction
xrandr is the command-line interface to the X Resize and Rotate extension. It lets you query and change screen resolution, refresh rate, orientation, and multi-monitor layout without restarting the X server.
xrandr works on X11 (Xorg) sessions. If you are on Wayland, xrandr may not be available or may only work in compatibility mode — use your desktop environment's display settings instead (Settings → Displays in GNOME, System Settings → Display and Monitor in KDE).
List available resolutions and outputs
Running xrandr with no arguments lists all connected displays (outputs) and the resolutions they support:
xrandr
Example output:
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
HDMI-1 connected primary 1920x1080+0+0 527mm x 296mm
1920x1080 60.00*+ 50.00 59.94
1280x1024 75.02 60.02
1024x768 75.08 60.00
eDP-1 connected 1366x768+1920+0 310mm x 170mm
1366x768 60.00*+
The * marks the current resolution; + marks the preferred resolution for that output.
Change resolution for a specific output
xrandr --output HDMI-1 --mode 1280x1024
Replace HDMI-1 with your output name from the listing above.
Change refresh rate
Set both resolution and refresh rate at once:
xrandr --output HDMI-1 --mode 1920x1080 --rate 50
Rotate the display
xrandr --output eDP-1 --rotate left # 90° counter-clockwise
xrandr --output eDP-1 --rotate right # 90° clockwise
xrandr --output eDP-1 --rotate inverted # upside down
xrandr --output eDP-1 --rotate normal # back to normal
Multiple monitors
Mirror both displays:
xrandr --output HDMI-1 --same-as eDP-1
Extend desktop — place HDMI-1 to the right of eDP-1:
xrandr --output HDMI-1 --right-of eDP-1
Turn off an output:
xrandr --output HDMI-1 --off
Set a specific output as the primary display:
xrandr --output HDMI-1 --primary
Make a resolution change permanent
Changes made with xrandr are lost on reboot. To make them stick:
On GNOME, KDE, or XFCE — use the display settings GUI. Those changes are remembered automatically across reboots.
On a minimal or tiling window manager — add the xrandr command to your session startup file:
echo 'xrandr --output HDMI-1 --mode 1920x1080 --rate 60' >> ~/.xsessionrc
System-wide — create a file in /etc/X11/xorg.conf.d/:
# /etc/X11/xorg.conf.d/10-monitor.conf
Section "Monitor"
Identifier "HDMI-1"
Option "PreferredMode" "1920x1080"
EndSection
Add a custom resolution
If your desired resolution is not listed, generate a modeline with cvt and add it:
cvt 1600 900 60
Output:
# 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
Modeline "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
Then add and apply it:
xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
xrandr --addmode HDMI-1 "1600x900_60.00"
xrandr --output HDMI-1 --mode "1600x900_60.00"
See also
arandr— a graphical front-end for xrandrcvt— compute VESA CVT modeline parametersxdpyinfo— query display information for X