How to disable a Laptop's Native Monitor via Command Line - Ubuntu 18.04

In Ubuntu 18.04, how can I disable a laptop's native monitor completely, using only the command line, in a manner where the laptop will only use an external monitor exclusively?

Background:

My uncle's laptop's screen went out a few years back, and after buying him a new laptop, I repurposed that old laptop (with the bad screen) to be a computer that hooks up to my TV (which does have a working screen) and I operate it with a remote keyboard that has a touch pad.

This laptop was running Ubuntu 16.04 (my favorite desktop of all time), but because 16.04 is about to lose support, this morning I upgraded it to 18.04.

On 16.04, I had the displays set up where, after login, Ubuntu 16.04 would simply turn off the laptop's native monitor (since it won't display anything but a faded white canvas anyway), and instead it would just exclusively use the TV as its primary monitor exclusively. That setup worked great.

However, after upgrading to 18.04, I cannot even login, because the login screen is only trying to display on the monitor that doesn't work. I think I may have logged in once (blindly), but all I ever saw (on the screen that does work) is the mouse-pointer. I cannot reach the settings screen where I may be able to turn off the bad monitor again (and only use the TV as the monitor - like before).

The only thing I'm able to do, in this new setup, is press Ctrl+Alt+F2 (I think it was) and this will display a command prompt on the TV.

From there, how can I configure the display settings so that the bad monitor is just turned off, and the TV's monitor is used exclusively?


Solution 1:

You can use xrandr to do that.

Without argument it gives you something like that:

Screen 0: minimum 1 x 1, current 3840 x 975, maximum 8192 x 8192 Virtual1 connected primary 1920x929+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 1920x929 60.00*+ 2560x1600 59.99
1920x1440 60.00
1856x1392 60.00
1792x1344 60.00
1920x1200 59.88
1600x1200 60.00
1680x1050 59.95
1400x1050 59.98
1280x1024 60.02
1440x900 59.89
1280x960 60.00
1360x768 60.02
1152x864 75.00
1280x768 59.87
1024x768 60.00
800x600 60.32
640x480 59.94
Virtual2 connected 1920x975+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm 1920x975 60.00*+ 2560x1600 59.99
1920x1440 60.00
1856x1392 60.00
1792x1344 60.00
1920x1200 59.88
1600x1200 60.00
1680x1050 59.95
1400x1050 59.98
1440x900 59.89
1280x960 60.00
1360x768 60.02
1280x800 59.81
1152x864 75.00
1280x768 59.87
1024x768 60.00
800x600 60.32
640x480 59.94

Virtual1 and Virtual2 are the monitor names, these may differ for you. In this example to disable Virtual2 the command would be:

xrandr --output Virtual2 --off