Configuring dual monitors on CentOS requires a different approach depending on whether you are using the traditional X11 desktop environment or the newer Wayland compositor. This guide explains how to set up multiple displays for both environments, ensuring your productivity is maximized regardless of the underlying display server technology running on your system.
Determining Your Display Server
Before attempting any configuration changes, it is critical to identify which display server your CentOS session is currently using. Modern versions of CentOS, particularly CentOS Stream and later releases, default to Wayland for security and performance reasons. Older setups or specific server configurations may still rely on X11 (Xorg). The method used to configure monitors differs significantly between these two systems, so applying X11 instructions to a Wayland session will likely result in errors or no visible change.
To check your current display server, open a terminal window and run the following command:
echo $XDG_SESSION_TYPE
If the output is
x11, you are using the legacy X server. If the output is
wayland, you are using the modern Wayland compositor. Additionally, you can verify this by looking at the login screen; if you see an option to select "GNOME" versus "GNOME on Xorg," the latter indicates X11, while the former typically indicates Wayland. Knowing this distinction prevents wasted time troubleshooting commands that are incompatible with your current environment.
Configuring Dual Monitors on Wayland
Wayland handles display configuration through the desktop environment's native settings rather than low-level command-line tools like
xrandr. For most CentOS users running the GNOME desktop environment, the process is intuitive and graphical.
Start by connecting both monitors to your system and ensuring they are powered on. Log into your GNOME session. Navigate to the
Activities overview by clicking the top-left corner or pressing the Super key. From there, click on
Settings. In the Settings menu, scroll down to find the
Displays section.
Inside the Displays panel, you will see a visual representation of your connected monitors. They are usually labeled as 1 and 2. You can rearrange them by dragging the boxes to match their physical arrangement on your desk. This ensures that moving your mouse off the right side of monitor one takes you to the left side of monitor two.
You can also adjust the resolution and refresh rate for each individual screen from dropdown menus within this same panel. If one monitor is not detected, ensure the cable connections are secure and try toggling the monitor off and on again. Once satisfied with the layout, close the Settings window; GNOME saves these preferences automatically.
For advanced users who require scripting or automation, Wayland does support some command-line tools, but they are less universal than
xrandr. Tools like
kscreen-doctor (for KDE) or specific GNOME extensions may be required for complex multi-monitor setups involving more than two screens or non-standard resolutions. However, for standard dual-head setups, the GUI method is the most reliable and supported path.
Configuring Dual Monitors on X11
If your system is confirmed to be running X11, you have more granular control via the command line using the
xrandr utility. This tool allows you to query connected outputs and set precise positioning and resolution parameters.
First, open a terminal and run
xrandr without arguments. This will list all available video outputs (such as HDMI-1, DP-1, VGA-1) and their current status. Look for lines that say "connected" to identify your active monitors.
To arrange two monitors side-by-side, you can use the following command structure, replacing the output names with those found in your previous step:
xrandr --output HDMI-1 --primary --mode 1920x1080 --pos 0x0 --output DP-1 --mode 1920x1080 --pos 1920x0
This command sets HDMI-1 as the primary display at the origin (0,0) and places DP-1 immediately to its right at position (1920,0). If you want to extend the desktop rather than mirror it, this positional setup achieves that goal. To mirror the displays instead, use the
--same-as flag:
xrandr --output HDMI-1 --mode 1920x1080 --output DP-1 --same-as HDMI-1
While
xrandr provides powerful control, these settings are temporary and will reset upon reboot. To make them permanent, you must add the command to your startup applications. In GNOME on X11, you can do this by going to Settings > Applications > Startup, adding a new entry that runs your
xrandr script. Alternatively, you can place the command in your
.xprofile or
.bashrc file, though the GUI method is generally safer and easier to manage.
It is worth noting that some hardware drivers, particularly for older NVIDIA cards, may require additional configuration in the
xorg.conf file to work seamlessly with
xrandr. If you encounter issues where the second monitor remains black or unrecognized, checking the driver logs in
/var/log/Xorg.0.log can provide diagnostic clues.
Troubleshooting Common Issues
Regardless of the display server, several common issues can arise when setting up dual heads. One frequent problem is detection failure. If a monitor is not listed in either the GNOME Settings or the
xrandr output, check the physical connections. Try a different cable or port to rule out hardware faults. Another issue is incorrect orientation. If the image appears rotated, you can correct this in the GUI settings or via
xrandr using the
--rotate left/right/inverted flags.
Performance lags on the secondary monitor might indicate a bandwidth bottleneck, especially with high-resolution displays over HDMI. Ensure you are using high-quality cables rated for the resolution and refresh rate you intend to use. For users managing servers remotely, remember that configuring local displays does not affect SSH sessions, which remain text-based unless explicitly configured otherwise. For more information on remote access configurations, you might find our guide on
Troubleshooting SSH Port Change Issues in Almalinux9 helpful for understanding network layer configurations that complement display setups.
Frequently Asked Questions
Can I use xrandr on Wayland?
No,
xrandr is designed specifically for the X11 display server and will not work on Wayland sessions. Attempting to run it will either return an error or have no effect. You must use the desktop environment's native settings interface instead.
How do I make xrandr settings permanent?
To persist
xrandr configurations across reboots, add the command to your user’s startup applications. In GNOME, this is done via Settings > Applications > Startup. You can also create a shell script containing the commands and execute it upon login.
Why is my second monitor not detected?
Detection failures are often caused by loose cables, faulty ports, or driver issues. Verify the physical connection first. If the hardware is fine, check your graphics driver installation and ensure it supports the specific monitor model. Rebooting the system after connecting the monitor can also help trigger detection.
What is the difference between extending and mirroring displays?
Extending displays treats the monitors as one large workspace, allowing you to drag windows between them. Mirroring duplicates the exact same content on both screens simultaneously. Extending is ideal for productivity, while mirroring is useful for presentations.
Does this guide apply to CentOS Stream?
Yes, the principles for Wayland and X11 configuration apply to CentOS Stream as well. Since CentOS Stream is closely aligned with Red Hat Enterprise Linux (RHEL), the display server behaviors and available tools are identical to those described in this article.