How to change the primary monitor in Ubuntu or other Linux distributions

(1 vote, average 5.00 out of 5)

Using dual or multiple monitors in Linux is relatively straightforward as most monitors are automatically detected on the major distributions. However, Gnome does not give an option for specifying which monitor is the primary - that is to say the monitor which holds the panels by default and is considered the 'default' display. Fortunately, the xrandr utility can easily switch which monitor is the primary. Copy and paste the following script into a text file called

Monitor Switcher Script
# Author: Andrew Martin
# Credit:
echo "Enter the primary display from the following:"			# prompt for the display
xrandr --prop | grep "[^dis]connected" | cut --delimiter=" " -f1	# query connected monitors
read choice								# read the users's choice of monitor
xrandr --output $choice --primary					# set the primary monitor

Once saved, make it executable by typing chmod +x into the terminal. Then, run it by typing ./ The script will then display a list of all detected monitors - type in the displayed name of the monitor you wish to make primary and hit enter. The script will then change the primary monitor immediately. Below is a sample run of the script:


$ ./
Enter the primary display from the following:



Partner Links:
Last Updated on Thursday, 30 September 2010 21:00  
Related Articles

» Redirect all output in shell script to a file

Redirecting a single command in a script to a file is straight-forward using the > syntax. For example, to redirect all STDERR output:1echo "hello, world" 2>> /tmp/filename.logTo redirect all lines of a Bash script to a file, add a scope around all of the lines and then redirect the scope to a file. For example:123456(echo "this is line 1 of my script"cat /proc/cpuinfodmesgecho "this is the end of my script") 2>> /tmp/filename.logThis allows you to capture all output of a script...

» How to Grep Output of a Program in a Linux Terminal

Grepping the output of a script or program in a linux terminal is very straightforward.  Run the script or program and pipe the output to grep, leaving the file designation empty.myprog -h | grep "Usage"The vertical bar indicates a piped output to a different program -- in this case, grep.  The example above will return all lines which contain the substring "Usage".

» How to Make Fonts on Ubuntu Linux Look Crisp Like on Microsoft Windows

Have you noticed that fonts on Linux distributions (like Ubuntu) appear fuzzy compared to Microsoft Windows? This is because Ubuntu is using a font display technique called "hinting" which draws the fonts more accurately but can appear blurry to users used to Windows. Below is an example of the difference between Polished Fonts (the Ubuntu default) and Sharp Fonts (the Windows default):Thanks to for the screenshot.InstallationIt is possible to make Ubuntu (and other Linux distributions) render...