1. Overview
We often use the console or terminal with a dedicated desktop environment and there’s usually nothing tricky about changing its font size. However, in some cases, we might find ourselves without the help of a graphical user interface (GUI). For example, using an Ubuntu server or barebones Raspberry Pi on a high-resolution screen might force us to switch to a bigger screen font size.
In this tutorial, we’ll learn how to change the console font size in a non-graphical Linux environment.
2. Modifying the console-setup File
If we’re using a DEB-based system like Ubuntu, we can tinker with the console-setup configuration file to change the console font and its size.
2.1. Using dpkg-reconfigure
An often-used approach to tweak the console-setup package is through using the dpkg-reconfigure command. Since console-setup is a system config file, we’ll need sudo privileges to modify its content:
$ sudo dpkg-reconfigure console-setup
Let’s check our current font setup as we run the command:
The dpgk-reconfigure tool launches a setup screen where we can use the arrow keys to navigate through options and the Enter key to confirm our selection. For our purposes, we’ll keep the default choices for the first two configuration questions:
- UTF-8 for the console’s encoding step
- Guess optimal character set for the character set for the console step
Then, we’ll change the font to, let’s say, TerminusBold for the third configuration question:
We may select other fonts from the menu but each font has a specific size range. For example, the Fixed font only ranges from 8×13 to 8×18, whereas, TerminusBold or Terminus provides a broader range from 6×12 to 16×32. In many cases, we may only choose the font based on its available sizes.
The final step is to select the font size to something that suits us. For example, let’s highlight 16×32 for a bigger-looking font:
The changes take effect in a moment without having to reboot the system because dpgk-reconfigure restarts the console-setup automatically after this step:
The console font is much bigger and more readable than before. Importantly, the changes to the console-setup are persistent, not temporary.
2.2. Using a Text Editor
The console-setup is just a configuration file that’s usually located in /etc/default/console-setup. So, rather than using the dpkg-reconfigure command to modify it, let’s do that directly using nano or any text editor at our disposal:
$ sudo nano /etc/default/console-setup
Just like before, we’ll change only two options, the font and its size. To do that, we assign TerminusBold to FONTFACE and 16×32 to FONTSIZE in the console-setup config file:
FONTFACE="TerminusBold"
FONTSIZE="16x32"
We may also edit console-setup to choose other valid fonts and sizes:
- Fixed (sizes 8×13, 8×14, 8×15, 8×16, and 8×18)
- Terminus (sizes 6×12, 8×14, 8×16, 10×20, 12×24, 14×28, and 16×32)
- TerminusBold (sizes 8×14, 8×16, 10×20, 12×24, 14×28, and 16×32)
- TerminusBoldVGA (sizes 8×14 and 8×16)
After saving the file, let’s restart the console-setup for the changes to take effect:
$ sudo service console-setup restart
We may also run the setupcon command to apply the changes as it’s part of the console-setup package.
Just as before, the system registers and applies the changes in a moment.
3. Changing the Font to Affect the Size
In the previous examples, we can notice that each font has its specific size range. However, this doesn’t mean we’re choosing the font and then changing its size, but rather just choosing a font with that specific size.
For example, when we select TerminusBold with a size of 16×32, the system actually selects a font file called [codeset]-TerminusBold32x16.psf.gz.
3.1. Changing the Font Temporarily With setfont
If each font file has a specific size, then we can set the preferred font based on the size directly with the setfont command.
First, let’s check the available fonts on our system in /usr/share/consolefonts or /usr/share/kbd/consolefonts by running the ls command:
$ ls /usr/share/consolefonts
...
Lat15-TerminusBold14.psf.gz
Lat15-TerminusBold16.psf.gz
Lat15-TerminusBold18x10.psf.gz
Lat15-TerminusBold20x10.psf.gz
Lat15-TerminusBold22x11.psf.gz
Lat15-TerminusBold24x12.psf.gz
Lat15-TerminusBold28x14.psf.gz
Lat15-TerminusBold32x16.psf.gz
...
Contrary to the previous examples where we let the system automatically guess the codeset, we should now indicate it manually. The codeset or character set of the font file is shown in the first part the filename, before the dash.
Let’s change the console font to TerminusBold with a size of 16×32 using the Latin 1 and 5 character set:
$ setfont Lat15-TerminusBold32x16
The effect of the command is immediate, but it only temporarily sets Lat15-TerminusBold32x16.psf.gz as the console font for the current session.
Importantly, the size in the font filenames is structured as 32×16 (height x width), contrary to the previous methods, where it was 16×32 (width x height).
3.2. Double the Size of a Small Font
If we only have a font with a size of 16×16 or smaller, we can still make it bigger by leveraging the -d switch of the setfont command to double its size:
$ setfont -d Lat15-TerminusBold16
This option is often useful if we’re using a high-density screen.
3.3. Changing the Font Permanently
Using the vconsole.conf file is a simple way to change the font permanently, especially if the system doesn’t have console-setup. This works by editing or creating the /etc/vconsole.conf file to assign a new font for the console:
$ nano /etc/vconsole.conf
FONT="Lat15-TerminusBold32x16"
We set the FONT variable to the font file Lat15-TerminusBold32x16, (minus its extension .psf.gz). Now, we can reboot the system to apply the changes or simply restart the *systemd*‘s vconsole service.
If the above fails, the best next thing is to copy-paste our previous setfont command into our bashrc file:
$ nano ./bashrc
...
setfont -d Lat15-TerminusBold32x16
Since the system invokes the bashrc file every time we log in, our console font will always be set to Lat15-TerminusBold32x16.
4. Conclusion
In this article, we talked about different methods to change the console font size like editing console-setup and vconsole.conf, or simply executing the setfont command.
In conclusion, even though we may know multiple ways to change the screen font size, it’s always best to choose the most fitting method for our specific needs.