There are three methods to set the default font or change font size on Linux virtual consoles.
- Temporary changing the default font and font size in the current session only
- Permanently changing the font and font size for all users
- Changing the default font and font size for a specific user
Let's understand each method in detail.
Temporary changing the font and font size in the current session only
The setfont command sets and changes the font and font size in the current session. This command uses the following syntax.
#setfont [New Console Font Name]
This command accepts the console font name and font size as the argument. For example, the following command sets the console font to Sun and its size to 12x22.
#setfont sun12x22
This command applies the change immediately. It updates the font as soon as you hit the Enter key.
It changes the font in the current session only. When you restart the system, the font sets back to the default.
Viewing all installed and available console fonts
Linux stores all console fonts in the /usr/lib/kbd/consolefonts/ directory. To view these fonts and their sizes, you can use the following command.
#ls /usr/lib/kbd/consolefonts/
The following image shows the output of this command.
As we can see in the above output, many fonts are available in different sizes. Of the available fonts, you can pick any font and font size.
Permanently changing the font and font size for all users
Linux saves the default font name in the /etc/vconsole.conf file. When we start Linux, it reads this file to set the default console font and font size.
If we update the default font name and font size in this file, the default font and font size will be changed for all users. You can use any text editor to edit this file.
Open this file, change the FONT directive, save the file, and restart the system.
When the system starts again, it reads the /etc/vconsole.conf file and sets the updated font as the default font for all users.
Changing the font and font size for a specific user
The /etc/vconsole.conf file sets the default font for all users. If you want to set the custom font for a specific user, you need to set the font in the .bash_profile file. The .bash_profile file is a script file. It saves user-specific settings. Linux reads and executes this file when the user log in. We can use this file to set the default font for the user.
Let's take an example.
Log in from a user and switch to the home directory. Open the .bash_profile file and add the following lines at the end of the file.
#Setting the custom font setfont [font name]
The first line is a comment. Linux ignores any lines that start with a # in the script file.
The second line calls the setfont command. We have already discussed the setfont command. This command sets the specified font as the default font in the current session.
Since Linux executes this script file each time the user login, the user will get a custom font every time.
The .bash_profile file only defines the user's profile. It does not affect other users' profiles. If we define a custom font in this file, then only the user who has this profile will get the custom font.
That's all for this tutorial. In this tutorial, we learn how to change the default font and font size on Linux virtual consoles.