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


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

# 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:


This article has been reposted from