How to Set Main Monitor with Terminal
Forget all the fancy GUI tools and their supposed ‘ease of use.’ Most of the time, they just add another layer of abstraction that breaks when you least expect it.
I remember spending a solid afternoon, staring at a blank screen after a botched update, just trying to get my dual monitors to play nice. Hours wasted. Eventually, I ended up wrestling with xrandr, muttering curses under my breath, but that’s when I finally figured out how to set main monitor with terminal.
It’s not about memorizing obscure commands; it’s about understanding the system. And honestly, once you get it, it’s faster than clicking through a dozen menus.
This isn’t your grandma’s computer lesson. We’re going to get our hands dirty.
Getting Your Display Info
First things first, you need to know what the system sees. When you plug in a monitor, your Linux system identifies it with a name. Think of it like a serial number for your screen.
Run this command:
xrandr
This little utility is your best friend for display management in X11. It will spit out a list of connected outputs (like `DP-1`, `HDMI-1`, `VGA-1`) and available resolutions for each. Don’t worry if the names look weird; they correspond to your physical ports.
Look for the ones that are ‘connected’. Sometimes, a monitor might show up but not be actively ‘connected’ if the cable is loose or the monitor is powered off. I once spent an entire morning troubleshooting why my second monitor wasn’t showing up, only to find out the power strip was accidentally switched off. Felt like a complete idiot, but hey, we’ve all been there. It was the fourth time I’d made a similar, embarrassingly simple mistake that week.
Figuring Out Your Resolution and Refresh Rate
Okay, so you know your monitor’s name. Now, what can it actually do? `xrandr` also shows you the resolutions and refresh rates your monitor supports. You’ll see a list of modes underneath each connected output.
Usually, there’s one marked with an asterisk (`*`) and the word ‘current’ — that’s what’s being used right now. You’ll see numbers like 1920×1080 and refresh rates like 60.00 Hz. You can also see modes that are ‘preferred’.
Sometimes, the default isn’t the best. I once had a monitor that was happy to run at 144Hz, but the system defaulted to 60Hz. The difference was night and day, especially when scrolling or playing games. The mouse felt sluggish, like trying to push a boat through thick mud. (See Also: How To Put 144hz Monitor At 144hz )
Pro Tip: If you’re not seeing the resolution or refresh rate you know your monitor supports, it might be a driver issue or the cable itself isn’t capable. I spent around $150 testing three different HDMI cables before realizing the cheap one I got from a no-name brand just couldn’t handle the bandwidth for 4K at 120Hz.
Setting the Main Display
This is where the rubber meets the road. You’ve identified your monitors, and you know their names. Now, you tell the system which one is the boss.
The command structure generally looks like this:
xrandr --output [MONITOR_NAM --primary --mode [RESOLUTION] --rate [REFRESH_RAT
Let’s break it down:
--output [MONITOR_NAM: This specifies which monitor you’re configuring. So, if your main monitor is `DP-1`, you’ll use `–output DP-1`.
--primary: This is the magic flag that designates this monitor as the main one. This is where your taskbar and system notifications will typically appear.
--mode [RESOLUTION]: Sets the screen resolution, like `1920×1080`.
--rate [REFRESH_RAT: Sets the refresh rate, like `60.00`. You can omit this if you want to stick with the default or if the specific rate isn’t critical.
So, to set `DP-1` as your primary monitor at 1920×1080 resolution with a 60Hz refresh rate, you’d type:
xrandr --output DP-1 --primary --mode 1920x1080 --rate 60.00
(See Also:
How To Switch An Acer Monitor To Hdmi
)
You can also position your secondary monitors relative to your primary one. For example, to put `HDMI-1` to the right of `DP-1`:
xrandr --output HDMI-1 --right-of DP-1 --mode 1920x1080 --rate 60.00
The ability to precisely dictate monitor placement via command line is frankly astonishing, like a conductor directing an orchestra of pixels, each with its own tempo and position. It’s far more granular than just dragging boxes in a GUI.
Making It Stick: Permanent Configuration
Running `xrandr` commands manually is fine for a one-off fix, but you want this to happen every time you boot up, right? Nobody wants to reconfigure their displays after every reboot.
How you do this depends on your desktop environment. For GNOME, KDE, XFCE, and others, there’s usually a display settings application that can save your configuration. But if you’re running a minimal setup or want absolute control, you’ll likely need to create a startup script.
A common place for this is in a file like `~/.xprofile` or `~/.config/autostart/monitor.desktop`. You just put your `xrandr` commands in there. Make sure the script is executable!
Example for `~/.xprofile`:
“`bash
xrandr –output DP-1 –primary –mode 1920×1080 –rate 60.00
xrandr –output HDMI-1 –right-of DP-1 –mode 1920×1080 –rate 60.00
“` (See Also: How To Monitor My Sleep With Apple Watch )
A lot of folks online will tell you to put this in `/etc/X11/xorg.conf` or `xorg.conf.d` files. Honestly, I’ve found that to be way more complicated than it needs to be, and a single typo can hose your entire graphical session. I tried that route once, spent two days trying to fix a misconfigured `xorg.conf` file that kept dropping me to a black screen. It was like trying to perform brain surgery with a butter knife.
The xrandr method is simpler and, in my experience, more reliable for most users. The Graphics, Video and Display Association (GVDA) actually recommends checking your display’s native resolution for optimal clarity, which is exactly what you’re doing when you check the `xrandr` modes. It’s about getting the best out of what you have.
Troubleshooting Common Display Issues
So, you’ve run the commands, and things still aren’t right. What gives?
1. Monitor Not Detected: Check cables, ensure the monitor is powered on, and try a different port or cable. Run `ls /sys/class/drm/` to see if your graphics card is even recognized by the kernel.
2. Wrong Resolution/Refresh Rate Available: This often points to graphics drivers. Make sure you have the proprietary drivers installed if you’re using NVIDIA or AMD, or that your open-source drivers are up-to-date for Intel.
3. Display is ‘Flipped’ or Rotated Incorrectly: Use the `xrandr –output [MONITOR_NAM –rotate [left|right|inverted|normal]` command. For instance, `–rotate right` will turn it 90 degrees clockwise. I once accidentally set a monitor to ‘inverted’ and spent five minutes trying to figure out why everything was upside down. It looked like a Salvador Dali painting gone wrong.
4. Mouse Cursor Jumps or Isn’t Smooth: This is usually a refresh rate issue. Ensure you’re setting the highest supported refresh rate for all your displays. The difference in perceived smoothness can be dramatic; it’s like going from a flip-book animation to a real movie.
5. Extended Desktop Doesn’t Work as Expected: Double-check your `–left-of`, `–right-of`, `–above`, or `–below` flags. Sometimes monitors are just in the wrong spot relative to each other. I had my secondary monitor set to the right, but it was actually physically to the left of my primary. Moving the cursor was like playing a frustrating game of whack-a-mole.
| Display Output | Primary? | Resolution | Refresh Rate (Hz) | My Verdict |
|---|---|---|---|---|
| DP-1 | Yes | 1920×1080 | 144.00 | Excellent for gaming, sharp text. |
| HDMI-1 | No | 2560×1440 | 75.00 | Good for productivity, but higher refresh would be nicer. |
| VGA-1 | No | 1024×768 | 60.00 | Barely usable for anything modern. Avoid if possible. |
Final Thoughts
So there you have it. Getting your displays configured from the command line isn’t some dark art. It’s a practical skill that saves you headaches and gives you more control than any graphical interface ever will.
If you’re stuck with how to set main monitor with terminal, remember to check `xrandr` for your output names and available modes first.
Try setting your primary display tonight, and then tomorrow, spend just five minutes seeing if you can reposition your secondary monitor using `–right-of` or `–above`. You might be surprised at how intuitive it feels after a bit of practice.
Honestly, once you ditch the GUI for this, you’ll wonder why you ever bothered with the mouse for something so simple.
Recommended For You



