
In this article, we will guide you through the process of changing the display resolution and scaling on Ubuntu 18.04 using the command line. This can be particularly useful for system administrators and developers who prefer to use the terminal over the graphical user interface.
To change the display resolution and scaling on Ubuntu 18.04 using the command line, you can use the xrandr
command. Identify your display output using xrandr
, then use the --mode
parameter to set the resolution and the --scale
parameter to adjust the scaling factor. You can also automate this process using the xdotool
command.
Understanding the xrandr Command
The command we’ll be using to accomplish this task is xrandr
. This command is a standard tool included with most Linux distributions. It is used to set the size, orientation, and/or reflection of the outputs for a screen.
To get started, open your terminal. This can be done by pressing Ctrl + Alt + T
or by searching for ‘terminal’ in the application launcher.
Identifying Your Display Output
Before we can change the display settings, we need to identify the output name of your display. This can be done by running the xrandr
command without any parameters:
xrandr
This will display a list of connected displays along with their supported resolutions. The output name is usually something like VGA
, HDMI-0
, DP-1
, etc. Look for the line that has the word connected
. The first word on that line is your output name.
Changing Display Resolution
After identifying your display output, you can change the resolution using the --mode
parameter followed by the desired resolution. For example, if your output name is DP-1
and you want to set the resolution to 1024x768
, you would use the following command:
xrandr --output DP-1 --mode 1024x768
In this command, --output
specifies the display output, and --mode
sets the resolution.
Adjusting Display Scaling
Similarly, you can adjust the scaling using the --scale
parameter followed by the scaling factor. For example, to set the scaling to 100%, you would use the following command:
xrandr --output DP-1 --scale 1x1
In this command, --scale
sets the scaling factor. The value 1x1
represents 100% scaling. If you wanted to set the scaling to 200%, you would use 2x2
.
Automating the Process
If you need to change the display settings frequently, you can automate this process using the xdotool
command. This command can simulate keyboard input and mouse activity, move and resize windows, etc.
For example, to automatically call xrandr
when an xterm
window gets focus, you would use the following command:
xdotool search --class xterm behave %@ focus exec xrandr --output DP-1 --mode 1024x768
In this command, search --class xterm
looks for windows with the class name ‘xterm’, behave %@ focus exec
specifies that the following command should be executed when the window gets focus, and xrandr --output DP-1 --mode 1024x768
is the command to be executed.
Conclusion
In this article, we’ve covered how to change the display resolution and scaling using the command line in Ubuntu 18.04. We’ve also discussed how to automate this process using xdotool
. Whether you’re a system administrator or a developer, understanding how to adjust these settings can be extremely useful in many scenarios.
For more information, you can refer to the man xrandr
manual page by typing man xrandr
into your terminal. You can also visit the official xrandr documentation for more detailed information.
To open the terminal in Ubuntu 18.04, you can press Ctrl + Alt + T
or search for ‘terminal’ in the application launcher.
The xrandr
command is used to set the size, orientation, and/or reflection of the outputs for a screen in Linux.
You can identify the output name of your display by running the xrandr
command without any parameters and looking for the line that has the word ‘connected’. The first word on that line is your output name.
To change the display resolution using the command line, you can use the xrandr --output [output name] --mode [resolution]
command. Replace [output name]
with the name of your display output and [resolution]
with the desired resolution.
To adjust the display scaling using the command line, you can use the xrandr --output [output name] --scale [scaling factor]
command. Replace [output name]
with the name of your display output and [scaling factor]
with the desired scaling factor (e.g., 2x2
for 200% scaling).
Yes, you can automate the process of changing display settings using the xdotool
command. It can simulate keyboard input and mouse activity. For example, you can use xdotool search --class [window class] behave %@ focus exec xrandr --output [output name] --mode [resolution]
to call xrandr
automatically when a specific window gets focus.
You can refer to the man xrandr
manual page by typing man xrandr
into your terminal. You can also visit the official xrandr documentation for more detailed information.