Configure Multiple Monitors on Ubuntu With xrandr
A second screen can make an Ubuntu desktop far more comfortable for coding, editing documents, monitoring servers, or keeping a browser open beside a terminal. Ubuntu usually detects connected displays automatically, but the default arrangement may place them in the wrong order, use an unsuitable resolution, or mirror the desktop when an extended workspace is wanted.
The xrandr command-line utility provides detailed control over monitors running through the X.Org display server. It can identify connected outputs, list supported modes, set resolutions and refresh rates, rotate a display, and position screens relative to one another. These settings are useful when the graphical display panel does not expose the option you need.
The instructions apply to common Ubuntu releases using GNOME on X.Org, including systems installed on desktop PCs, laptops, and mini computers. Hardware sold through Australian retailers such as Officeworks, Scorptec, and Umart can vary widely, so a USB-C dock, HDMI adapter, or older VGA converter may affect which outputs Ubuntu detects.
For wider Linux news, application reviews, and desktop guidance, Ubuntu Linux coverage offers useful background alongside this hands-on configuration guide. Before changing display settings, save open work and note your current layout so you can restore it if a command produces an unexpected result.
Check The Display Server And Connected Outputs
Open a terminal with Ctrl + Alt + T, then run:
echo $XDG_SESSION_TYPE
xrandr --query
The first command reports whether the current session is using x11 or wayland. The second prints every display output known to the session. Connected screens usually appear with a name such as HDMI-1, DP-1, eDP-1, or HDMI-0, followed by the word connected. A laptop’s built-in panel is often identified as eDP-1, while an external monitor may use DisplayPort or HDMI.
The query also shows available modes. A line such as 1920x1080 60.00*+ means that 1920 by 1080 is currently active at 60 Hz. An asterisk marks the active mode, and a plus sign commonly indicates the preferred mode. If an output says disconnected, check the cable, dock, adapter, input selection on the monitor, and graphics hardware before trying more commands.
On a laptop used between home and an office in Melbourne or Brisbane, the output names can remain stable while the connected hardware changes. A USB-C dock may expose different names from a direct HDMI connection. Run xrandr --query after reconnecting equipment rather than relying on an old command copied from another machine.
Arrange Two Screens Side By Side
To place a second monitor to the right of the laptop display, use a command similar to this:
xrandr --output eDP-1 --auto \
--output HDMI-1 --auto --right-of eDP-1
Replace the output names with those shown on your computer. The --auto option selects a usable preferred mode. Related placement options include --left-of, --above, and --below. For a monitor positioned at an angle or on a portrait stand, --rotate left, --rotate right, or --rotate normal changes its orientation.
A layout can also be defined with explicit resolutions. For example:
xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 \
--output HDMI-1 --mode 2560x1440 --pos 1920x0
Here the external display begins at horizontal coordinate 1920, directly after the laptop panel. This works well when both screens share their top edge, although different physical heights may make the pointer appear to jump vertically at the boundary. A graphical display tool is often easier for fine alignment, while xrandr is better for repeatable layouts and scripts.
To mirror the laptop screen instead, run:
xrandr --output HDMI-1 --auto --same-as eDP-1
Mirroring requires a compatible mode. If the displays support different resolutions, Ubuntu may choose a common mode that looks soft on one panel. Extended desktop mode is generally preferable for a workstation, especially when using a 4K monitor with a smaller notebook display.
Select Resolution Refresh Rate And Scaling
A monitor may support several refresh rates for the same resolution. To select one explicitly, combine --mode with --rate:
xrandr --output HDMI-1 --mode 2560x1440 --rate 75
Use a mode and refresh rate printed by xrandr --query; inventing a value will fail. A high refresh rate can improve cursor movement and scrolling, but it may require a suitable DisplayPort cable, HDMI standard, graphics processor, and dock. Cheap adapters are a common reason a screen is limited to 30 Hz or a lower resolution.
Laptop panels and external monitors can also have different pixel densities. X.Org’s --scale option changes the rendered size, though it is not always as clean as desktop-environment fractional scaling:
xrandr --output HDMI-1 --scale 1x1
For a portrait monitor, combine rotation with placement:
xrandr --output DP-1 --mode 1920x1080 --rotate left \
--left-of eDP-1
After changing a mode, inspect the result with xrandr --query. Watch for flickering, black borders, blurry text, or a refresh rate that feels uncomfortable. Australian users connecting a desktop to a television in a Sydney apartment may also need to disable overscan in the television’s picture settings or select a “PC” input mode.
Fix Common xrandr Errors
The error Can't open display usually means the command is being run outside the graphical session, through an incorrect remote shell, or as a user without access to the active display. Running xrandr from a normal terminal inside the Ubuntu desktop is the safest starting point. When connecting through SSH, X11 forwarding or the correct DISPLAY and authentication settings may be required.
A frequent problem is cannot find mode. This indicates that the requested resolution is not advertised by the monitor or adapter. First check the exact spelling and dimensions returned by xrandr. If a custom mode is genuinely necessary, create one with cvt, add it to the output, and activate it:
cvt 1920 1080 60
The command prints a modeline. Copy that modeline into xrandr --newmode, then attach it to the output with --addmode. A typical sequence looks like this, although the modeline values must match the output from cvt:
xrandr --newmode "1920x1080_60.00" 173.00 \
1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI-1 "1920x1080_60.00"
xrandr --output HDMI-1 --mode "1920x1080_60.00"
Do not force a mode that the display, cable, or adapter cannot handle. If the screen goes blank, wait for the command to time out or switch to another virtual terminal with Ctrl + Alt + F3, log in, and restore a safer mode. Be particularly cautious with obscure downloads promising display utilities or “activation” tools; crack downloads can contain malware and are unrelated to legitimate Ubuntu display configuration.
Make The Layout Persistent
A command entered in a terminal normally lasts only until the X.Org session ends. To reuse a layout, place the working command in a small script. Create a directory for personal executables and a script file:
mkdir -p ~/.local/bin
nano ~/.local/bin/two-screens
Add a command suited to the actual output names:
#!/usr/bin/env bash
xrandr --output eDP-1 --mode 1920x1080 --primary \
--output HDMI-1 --mode 2560x1440 --right-of eDP-1
Save the file, then make it executable:
chmod +x ~/.local/bin/two-screens
You can run it manually after logging in with ~/.local/bin/two-screens. To launch it automatically under an X.Org GNOME session, open “Startup Applications”, create a new entry, and use the script path as the command. Some Ubuntu versions also allow a desktop entry in ~/.config/autostart/.
Automatic startup is less reliable when using Wayland because xrandr controls X.Org’s RandR interface rather than Wayland’s display protocol. Under Wayland, use Settings, a desktop-specific tool, or compositor configuration instead. Ubuntu may offer an “Ubuntu on Xorg” session from the login screen; selecting it can make xrandr-based scripts work, although the choice may affect touchpad behaviour, fractional scaling, and other desktop features.
If a dock is sometimes absent at login, a startup script may execute before the monitor becomes available. In that case, run the script after connecting the dock, add a short delay such as sleep 3, or use a user service that retries the layout. Keep a fallback command handy:
xrandr --output eDP-1 --auto --primary \
--output HDMI-1 --off
Use Profiles For Home And Work
People who move between a home desk, a university lab, and a workplace often need several display arrangements. Rather than editing one long command repeatedly, create separate scripts such as home-monitor, office-dock, and projector. Each script can set its own output names, resolutions, primary screen, rotation, and placement.
For a home monitor on the right:
xrandr --output eDP-1 --auto --primary \
--output DP-1 --auto --right-of eDP-1
For a projector above the laptop:
xrandr --output eDP-1 --auto --primary \
--output HDMI-1 --mode 1920x1080 --above eDP-1
A primary display matters because GNOME usually places the top bar, login prompts, and new application windows there. Set it deliberately with --primary, especially when a large external screen is the main workspace. If a monitor is listed as connected but remains blank, check whether it has been disabled by a previous profile using --off.
Keep notes about which physical connector corresponds to each output. Labels on a desktop tower are often clearer than those on a dock, and a quick photo can help when reconnecting cables. Australian daylight-saving changes in states such as New South Wales and Victoria do not alter monitor geometry, but a laptop moved between locations may switch power profiles or docking behaviour, making it useful to test the layout after suspend and resume.
The most dependable process is simple: query the outputs, apply a temporary arrangement, verify resolution and refresh rate, then save the known-good command in a profile. For everyday use, the practical takeaway is to treat xrandr commands as hardware-specific recipes and keep a working single-screen fallback available whenever you connect a new monitor, dock, or adapter.