I finally reached the point where I’m comfortable using the terminal for most things on my linux computer. No longer a beginner, I ventured into learning even more about the linux system, diving deeper into bash. For example, I discovered you can customize the appearance of the terminal, add your own variables, and much more. To start small, I decided to change the font family. Back in my network engineering days, I always customized my terminals (specifically, SecureCRT) to look a certain way. Black background, green font, etc. I wanted to try to emulate that style from years ago. Here’s how I did it.
Step 1: Installing a new font
Since I’m relatively new to linux, I won’t claim these steps will work on all versions of linux. I’m really not sure. I’m using pop-os for now, which is a derivative of Ubuntu. Oh, and every step in this tutorial uses the terminal instead of the GUI. Like I said: if I’m going to become a linux power-user then I need to stick with bash.
Step 1a: Find a font
You can choose any font family you prefer. I recommend checking out Nerd Fonts. They have a great selection of mono-style fonts perfect for the terminal. I opted for MesloLG Nerd Font. Whichever font you prefer, right click on the download button and copy the link.
Step 1b: Download the font
Next, we have to download the font files and place them in a specific directory. Before we jump into that, head on over to your terminal and let’s see where your fonts are currently saved. Type in fc-list. You should see something similar to this:
username@hostname:~$ fc-list
/usr/share/fonts/truetype/noto/NotoSerifKannada-Bold.ttf: Noto Serif Kannada:style=Bold
/usr/share/fonts/truetype/noto/NotoLoopedLao-Bold.ttf: Noto Looped Lao,Noto Looped Lao Bold:style=Bold
/usr/share/fonts/truetype/noto/NotoSansGlagolitic-Regular.ttf: Noto Sans Glagolitic:style=Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Bold
/usr/share/fonts/opentype/urw-base35/NimbusRoman-Italic.otf: Nimbus Roman:style=Italic
/usr/share/fonts/opentype/fira/FiraSansCondensed-SemiBoldItalic.otf: Fira Sans Condensed,Fira Sans Condensed SemiBold:style=SemiBold Italic,Italic
/usr/share/fonts/opentype/fira/FiraSansCompressed-ExtraBold.otf: Fira Sans Compressed,Fira Sans Compressed ExtraBold:style=ExtraBold,Regular
/usr/share/fonts/truetype/noto/NotoSansNabataean-Regular.ttf: Noto Sans Nabataean:style=Regular
username@hostname:~$
As you can see, the default fonts that come with whichever linux distro you use are in /usr/share/fonts. Now that you know where that is, DON’T MESS WITH THAT FOLDER!.
Of course, you could put new fonts in there, but in my experience, messing with system directories and files breaks things when you don’t know what you’re doing. Instead, I learned there is almost always a user folder in your home directory associated with whatever setting or object you wish to add or modify.
So where should you install the new font? The folder you want to download the new font family to is /home/username/.local/share/fonts. It’s likely that the /fonts directory doesn’t exist yet but the /home/username/.local/share should. Follow these commands to verify.
username@hostname:~$ ls /home/username/.local/share
**applications** **evolution** **gstreamer-1.0** **man** 'session_migration-(null)'
**pipx** **flatpak** **gvfs-metadata** **mime** recently-used.xbel
**pop-transition** **color-schemes** **keyrings** **nano** **Trash**
Don’t worry if your output doesn’t look exactly like mine. The only thing you need to focus on is if there’s a folder called fonts. If the fonts directory doesn’t exist, create it like this:
username@hostname:~$ mkdir /home/username/.local/share/fonts
Feel free to run that same ls /home/username/.local/share command again and verify the fonts folder shows up. When you’re done that, it’s time to download the font.Make sure you still have that link copied from step 1. I’ll break down the command after the terminal block below.
For downloading the entire font family in a zip file, use this command:
username@hostname:~$ wget -P ~/Downloads/ https://yourfontdownloadlink.com/FontName.zip && unzip -d /home/username/.local/share/fonts/FontName ~/Downloads/FontName.zip && rm ~/Downloads/FontName.zip
Breaking down the commands
wget: the command to download files from the web
-P: a wget option to save files to a specific prefix or folder
~/Downloads the actual location we want the file to download to
https://yourfontdownloadlink.com/FontName.zip: the link to the zip file of the font you want. Make sure it ends in .zip
&&: logically stands for AND_IF, meaning run the first command and if that command ran successfully, run this next command
unzip: the default unzip command in bash
-d: an unzip option to extract the files into a different or specific directory
/home/username/.local/share/fonts/FontName: the new directory we want the extracted font files (or individual font file) located
~/Downloads/FontName.zip: the location and file name of the zip file
&&: we have one last command to run
rm: delete a file
~/Downloads/FontFamily.zip: the specific file to delete
# use this command if you want to download a specific .ttf file instead of the entire font family zip file:
username@hostname:~$ wget -P /home/username/.local/share/fonts/FontName https://yourfontdownloadlink.com/FontName.ttf
Explanation of command
Since this is a single file instead of a zipped folder, we only need one command. Let me break it down:
wget: the command to download files from the web
-P: a wget option to save files to a specific prefix or folder
/home/username/.local/share/fonts/FontName: the actual location we want the file to download to
https://yourfontdownloadlink.com/FontName.ttf: the link to the .ttf file of the font you want. Make sure it ends in .ttf
Step 3: Cache the new fonts in your home directory
You may need to run one final command to be able to use your newly downloaded font.
username@hostname:~$ fc-cache -rv
Explanation of command
fc-cache: tells linux to scan the font directories and build an updated font cache for applications to use
-rv: the r stands for really force and erases all the existing cache files and rescan; the v stands for verbose and will output details during the process
Step 4: Verify your font is in the updated cache
Run the command we ran in step 2 one last time to ensure the cache rescan detected your new fonts.
username@hostname:~$ fc-list
/home/username/.local/share/fonts/FontName/FontName-Regular.ttf: Font Name:style=Regular
/home/username/.local/share/fonts/FontName/FontName-Bold.ttf: Font Name:style=Bold
/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf: Noto Sans:style=Regular
/usr/share/fonts/truetype/noto/NotoSansHebrew-Bold.ttf: Noto Sans Hebrew:style=Bold
/usr/share/fonts/truetype/noto/NotoSansSoraSompeng-Bold.ttf: Noto Sans Sora Sompeng:style=Bold
Notice the /home/username/.local/share/fonts directory shows up in the list now.
Congrats! Now you can use a custom font in linux!