This guide walks you through configuring a permanent dual-monitor setup in Ubuntu, so your display arrangement, orientation, and resolution persist across reboots and monitor reconnects. You’ll learn how to use the built-in Settings app and the more powerful xrandr command-line tool, plus how to make the configuration stick with a startup script. No special hardware or software is required beyond your two monitors and a compatible graphics driver.
What You’ll Need
- A computer running Ubuntu (20.04 or newer recommended) with two monitors connected via HDMI, DisplayPort, VGA, or USB-C.
- A graphics driver that supports your hardware (the default open-source drivers usually work; for NVIDIA, install the proprietary driver via “Additional Drivers”).
- Basic familiarity with the terminal (Ctrl+Alt+T).
Step-by-Step
- Connect both monitors to your computer and power them on. Ubuntu should detect them automatically and mirror or extend the display by default.
- Open Settings by clicking the system menu (top-right corner) and selecting the gear icon, or by searching “Settings” in the Activities overview.
- Go to Displays in the left sidebar. You’ll see two rectangles representing your monitors, labeled with their names (e.g., “DELL U2720Q” and “Samsung S24R350”).
- Arrange the monitors to match your physical setup: click and drag the rectangles so they align the way the monitors sit on your desk. For example, if the second monitor is to the left of the first, drag its rectangle to the left of the primary one.
- Set the primary display: click on the monitor you want as your main screen (where the dock and menus appear) and toggle “Primary Display” on.
- Adjust resolution and orientation for each monitor by clicking on its rectangle and selecting the desired resolution (e.g., 1920×1080) and orientation (Landscape, Portrait, etc.) from the drop-downs.
- Choose the display mode: under the “Display Mode” section, select “Join Displays” (also called “Extend”) to have separate desktops across both monitors, or “Mirror” to show the same content on both.
- Click “Apply” at the top of the Displays window. A confirmation dialog will appear with a 15-second countdown. If the new arrangement looks correct, click “Keep Changes”; if not, the system will revert automatically.
- Test the setup by moving your mouse across the screens and dragging a window from one monitor to the other. Verify that the cursor moves in the correct direction (e.g., moving right should take you to the right monitor).
- Make it permanent: The Settings app usually saves your configuration automatically, but to ensure it survives a reboot or monitor disconnect, you’ll create a startup script using
xrandr(see next steps). - Open a terminal and run
xrandr --queryto list all connected outputs. Note the output names (e.g.,HDMI-1,DP-1,eDP-1) and their current resolutions and positions. - Determine the exact command to set your desired layout. For example, to place HDMI-1 to the left of eDP-1 at 1920×1080, use:
xrandr --output HDMI-1 --mode 1920x1080 --pos 0x0 --primary --output eDP-1 --mode 1920x1080 --pos 1920x0
Adjust the output names, resolutions, and positions to match your setup. The
--posvalues are in pixels; the second monitor’s X position equals the first monitor’s width. - Create a startup script: Use a text editor to create a file, e.g.,
~/.screenlayout/dual.sh, and paste the xrandr command(s) you just tested. Make it executable withchmod +x ~/.screenlayout/dual.sh. - Add the script to Startup Applications: Open “Startup Applications” from the Activities overview (or install it with
sudo apt install gnome-startup-applicationsif missing). Click “Add”, name it “Dual Monitor Setup”, and in the Command field enterbash ~/.screenlayout/dual.sh. Click “Add” again to save. - Reboot to test. Your monitors should come up in the configured arrangement automatically. If not, check the Troubleshooting section below.
Common Mistakes
- Using the wrong output names: xrandr output names vary by GPU and connection type. Always run
xrandr --queryfirst to get the exact names for your system. - Ignoring the primary display setting: If you don’t set a primary, the system may choose the first detected output, which might not be the one you want.
- Forgetting to make the script executable: A non-executable script won’t run at startup. Use
chmod +x. - Positioning monitors incorrectly: If the X positions don’t account for the widths of the monitors, the mouse may get stuck or jump unexpectedly. Double-check your math.
- Assuming the Settings app always persists: While it usually does, a monitor that isn’t connected at boot may cause the layout to reset. The xrandr script is more reliable for permanent setups.
Tips
- Use a single xrandr command that sets both outputs in one go, as shown above. This avoids flicker and ensures a consistent state.
- Save your layout with ARandR: Install
arandr(sudo apt install arandr), arrange your monitors graphically, and use “Save As” to generate a shell script. It’s a convenient way to create the startup script without typing xrandr commands manually. - Set different wallpapers per monitor: Right-click the desktop, choose “Change Background”, and use the “Add Picture” button to assign a separate wallpaper to each display.
- Use keyboard shortcuts to move windows between monitors:
Super+Shift+Left/Rightmoves the active window to the next/previous monitor. - If you use a laptop, consider using
xrandr --output eDP-1 --offin your script to disable the built-in screen when an external monitor is connected, but be careful: this will turn off the laptop screen permanently unless you adjust the script.
Troubleshooting
- Monitors not detected: Check cable connections and try a different port. Run
xrandr --queryto see if the output appears. If not, your GPU driver may not support the connection; install the correct driver via “Software & Updates > Additional Drivers”. - Resolution not available: Some monitors require a custom resolution. Use
cvt 1920 1080 60to generate a modeline, then add it withxrandr --newmodeandxrandr --addmode. This is advanced but works for many displays. - Configuration resets after reboot: Ensure your startup script is enabled in Startup Applications and that it runs without errors. Test the script manually in a terminal first.
- Mouse moves in the wrong direction: Go back to Settings > Displays and drag the monitor rectangles to match your physical layout. The order matters: if the second monitor is physically on the right, its rectangle should be to the right of the primary.
- Screen flickers or goes black: This often happens when the xrandr command sets an unsupported mode. Verify the resolution with
xrandr --queryand use exactly the mode listed. If the screen goes black, wait 15 seconds for the system to revert, or press Ctrl+Alt+F1 to switch to a terminal and fix the script. - When using NVIDIA, xrandr may not work: For NVIDIA GPUs, use the NVIDIA X Server Settings app (run
nvidia-settings) to configure your layout, and save the configuration to/etc/X11/xorg.confvia the “X Server Display Configuration” page. This is more reliable than xrandr for NVIDIA.
Frequently Asked Questions
Why does my monitor arrangement reset every time I unplug and replug the cable?
Ubuntu’s display manager may treat a disconnected monitor as a new device. The xrandr startup script will reapply your layout when you log in, but if you want the change to happen immediately upon reconnecting, you can create a udev rule or use a tool like autorandr to trigger the script on hotplug events.
Can I use different scaling factors on each monitor?
Yes. In Settings > Displays, select a monitor and choose a “Scale” value (e.g., 100%, 125%, 200%). This is especially useful when using a 4K monitor alongside a 1080p one. Note that fractional scaling may require experimental support on some desktop environments.
How do I set a different wallpaper on each monitor?
Right-click the desktop, select “Change Background”, and click the “Add Picture” button. Then, for each monitor, click the “Picture” drop-down and choose a different image. This works in GNOME and most other desktop environments.
What is the difference between “Join Displays” and “Mirror”?
“Join Displays” (extend) gives you two separate desktops, so you can drag windows between them and have different apps open on each. “Mirror” shows the exact same content on both monitors, which is useful for presentations but not for multitasking.
My monitors have different resolutions; how do I align them properly?
In Settings > Displays, drag the rectangles so that the bottom edges align (or top edges, depending on your preference). The system will automatically handle the difference in height, but you may need to adjust the vertical position if the mouse gets stuck at the boundary. In xrandr, you can set the Y position manually (e.g., --pos 1920x0 for the second monitor) to align the tops.
Will this work on Ubuntu variants like Kubuntu or Xubuntu?
Yes, the Settings app may look different, but the underlying xrandr commands work the same. For KDE, you can use System Settings > Display and Monitor; for XFCE, use Settings > Display. The startup script method works across all variants.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Fix Error 0x80072f76 0x20016 in Windows
- How to Backup and Restore Drivers in Windows 11
- Fix Windows Couldn’t Complete the Requested Changes
- Move to iOS Stuck? Fixes That Actually Work
- USB Bluetooth Dongle: What It Is and How It Works
- ADB Device Not Found Error on Windows: Fixed