Skip to main content

Command Palette

Search for a command to run...

Font Management Using Terminal

Updated
8 min read
R
Safety professional by day, Linux explorer by night.

Although installed fonts can be checked using a GUI, the terminal offers a uniform experience, regardless of your Linux distribution. In addition, the terminal can give you more power than the GUI can.

Font management

List all installed fonts

To see all complete family fonts:

fc-list

Or, if you want to save the list to a TXT file:

fc-list > "All my fonts.txt"

To see the font family names only:

fc-list : family | sort | uniq

To count the number of fonts:

fc-list | wc -l

Search a font

To search specific font name based on search keyword:

fc-list | grep -i myfont

📝 Info: myfont is the font name that you want to search.

Or check family name (sometimes different from file name):

fc-scan ~/Downloads/myfont.ttf | grep family

Check the fonts' locations

System-wide fonts (available for all user accounts):

ls /usr/share/fonts

Specific user:

ls ~/.local/share/fonts

History of many fonts' locations

Linux inherits its model from Unix, where systems were shared by multiple users simultaneously (servers, university machines, etc.). Because of that, separation of user data is strict:

  • System-wide resources → /usr/share/...

  • User-specific resources → ~/.local/share/...

Fonts on linux follow this model:

  • System-wide fonts: /usr/share/fonts

  • Per-user fonts: ~/.local/share/fonts

This segregation allows users to install fonts without root/admin access (no need to use "sudo"). As a result, different users can have different font sets, without any worry of conflicts or unwanted changes across accounts.

Font Sources

On Ubuntu, the most commonly used font format is TrueType Font (TTF). For example, Ubuntu, DejaVu, Liberation fonts, Noto. The main reason is because TTF works everywhere: UI, terminal, printing, web, apps and no special rendering requirements. Moreover, many open-source fonts are distributed as TTF.

Some free font sources:

Font installation

Install a font for specific user only

This allows each user to have different fonts.

mkdir -p ~/.local/share/fonts
cp ~/Downloads/myfont.ttf ~/.local/share/fonts/ 
fc-cache -f -v

Install a font for all users

sudo mkdir -p /usr/share/fonts/truetype/myfont
sudo cp ~/Downloads/myfont.ttf /usr/share/fonts/truetype/myfont/ 
sudo fc-cache -f -v 

📝 Info:

  • Change "myfont.ttf" with your desired font name.

  • Change "Downloads" with another directory if the font file is not in the Downloads directory.

Install font as a package

A font can be installed as a package using a way like this:

sudo apt install fonts-<package-name>*

📝 Info:

  • Change the <package name> with font package name that you want to install.

  • Symbol * after the package name means anything (characters or words) behind package-name.

Check the installed font packages

Checking installed fonts is the first step that you have to do:

  • to ensure whether the installation went properly, or

  • the targeted font in the uninstalling progress trully exists.

To check the font packages you have just installed:

dpkg -l | grep fonts

You will get a list like this:

ii  fonts-cantarell                                             0.303.1-1                           all          sans serif font family designed for on-screen readability
ii  fonts-crosextra-carlito                                     20220224-1                          all          Sans-serif font metric-compatible with Calibri font
ii  fonts-dejavu                                                2.37-6                              all          metapackage to pull in fonts-dejavu-core and fonts-dejavu-extra
ii  fonts-dejavu-core                                           2.37-6                              all          Vera font family derivate with additional characters
ii  fonts-dejavu-extra                                          2.37-6                              all          Vera font family derivate with additional characters (extra variants)
ii  fonts-droid-fallback                                        1:6.0.1r16-1.1                      all          handheld device font with extensive style and language support (fallback)
ii  fonts-liberation                                            1:1.07.4-11                         all          Fonts with the same metrics as Times, Arial and Courier
ii  fonts-noto-cjk                                              1:20220127+repack1-1                all          "No Tofu" font families with large Unicode coverage (CJK regular and bold)
ii  fonts-noto-mono                                             20201225-1                          all          "No Tofu" monospaced font family with large Unicode coverage
ii  fonts-quicksand                                             0.2016-2.1                          all          sans-serif font with round attributes
ii  fonts-urw-base35                                            20200910-7                          all          font set metric-compatible with the 35 PostScript Level 2 Base Fonts
ii  gsfonts                                                     2:20200910-7                        all          transitional dummy package (gsfonts -> fonts-urw-base35)
ii  libobasis25.8-ooofonts                                      25.8.4.2-2                          amd64        3rd party free fonts for LibreOffice 25.8.4.2
ii  libwoff1:amd64                                              1.0.2-2                             amd64        library for converting fonts to WOFF 2.0
ii  xfonts-100dpi                                               1:1.0.5                             all          100 dpi fonts for X
ii  xfonts-75dpi                                                1:1.0.5                             all          75 dpi fonts for X
ii  xfonts-base                                                 1:1.0.5+nmu1                        all          standard fonts for X
ii  xfonts-encodings                                            1:1.0.4-2.2                         all          Encodings for X.Org fonts
ii  xfonts-scalable                                             1:1.0.3-1.3                         all          scalable fonts for X
ii  xfonts-utils                                                1:7.7+6                             amd64        X Window System font utility programs

📝 Info: Some fonts are going to be used in the case study in uninstalling fonts.

⚠️ WARNING: Although a font cannot be found by dpkg -l | grep -i myfont.ttf, it doesn't mean the font is installed or uninstalled. Manual install can "hide" a font from the list using that code.

Uninstall a font

Sometimes, font family members can flood your font list. Imagine you wanna a font, but the more you scroll font list on an office application, the more you find fonts that you do not like or use. You can remove many of them (unwanted fonts) safely, but not blindly. The “too many fonts slow apps” suspicion is partly valid, especially for apps like LibreOffice or design tools.

Uninstall a font for specific user only

rm ~/.local/share/fonts/myfont.ttf
fc-cache -f

Uninstall a font for all users

sudo rm /usr/share/fonts/truetype/myfont/myfont.ttf
sudo fc-cache -f

Use sudo apt remove to remove remaining fonts. For example, the remaining fonts from the list above are: noto core, noto ui core, and noto mono.

sudo apt remove fonts-noto-core fonts-noto-ui-core fonts-noto-mono

If the font is found using dpkg -l | grep -i myfont.ttf, the font is installed as a package, then uninstalling can use sudo apt remove. For example, based on the list above, you wanna uninstall these fonts:

sudo apt remove fonts-noto-cjk
sudo apt remove fonts-noto-extra
sudo apt remove fonts-arphic-*

or:

sudo apt remove fonts-noto-cjk fonts-noto-extra fonts-arphic-*

📝 Info: Change all sample font names with your font names that will be uninstalled.

Rebuild cache.

fc-cache -f -v

If the target font was not installed as a package, check the font's location by using code in the "Check the fonts' locations" part above. And then, remove the target font manually.

rm ~/.local/share/fonts/myfont 
fc-cache -f -v

📝 Info:

  • "myfont" is the font name that you want to search.

  • Verify the uninstalling with fc-list : family | sort | uniq command.

Cannot uninstall

If a font cannot be uninstalled for some reason, just hide it. The below steps are intended to workaround 4 stubborn fonts that cannot be removed. Adjust the number of problematic fonts as you need.

Step 1 — Create a blacklist config

mkdir -p ~/.config/fontconfig/conf.d
nano ~/.config/fontconfig/conf.d/99-hide-unwanted-fonts.conf

💡 Tips: You can use any other code editor, not only nano, like gedit, sublime or something else, by changing the "nano" in the beginning of the code to open 99-hide-unwanted-fonts.conf file.

Step 2 — Create script to hide font

Copy the code below to the opened 99-hide-unwanted-fonts.conf file.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

  <!-- Hide ALL font1 -->
  <match target="pattern">
    <test name="family" compare="contains">
      <string>font1</string>
    </test>
    <edit name="family" mode="assign">
      <string>DoNotUse</string>
    </edit>
  </match>

  <!-- Hide ALL font2 / URW -->
  <match target="pattern">
    <test name="family" compare="contains">
      <string>font2</string>
    </test>
    <edit name="family" mode="assign">
      <string>DoNotUse</string>
    </edit>
  </match>

  <!-- Hide font3 -->
  <match target="pattern">
    <test name="family" compare="contains">
      <string>font3</string>
    </test>
    <edit name="family" mode="assign">
      <string>DoNotUse</string>
    </edit>
  </match>

  <!-- Hide font4 -->
  <match target="pattern">
    <test name="family" compare="contains">
      <string>font4</string>
    </test>
    <edit name="family" mode="assign">
      <string>DoNotUse</string>
    </edit>
  </match>

</fontconfig>

📝 Info: Change "font1" until "font4" with font name or part of font name.

Then save and close the file. To close and save a file in Nano, follow these steps:

  1. Press CTRL + X: This will prompt you to save the changes.

  2. If you have unsaved changes, Nano will ask if you want to save them. Press Y for yes.

  3. Then, it will ask for the filename. If you want to keep the same name, just press Enter. If you want to save it under a different name, type the new name and then press Enter.

Step 3 — Update cache

fc-cache -f -v

Step 4 — Verify uninstalling

fc-list | grep -i "font1\|font2\|font3\|font4"

or:

fc-match "font1"
fc-match "font2"
fc-match "font3"
fc-match "font4"

📝 Info:

  • Change "font1" until "font4" with font name or part of font name.

  • If hiding code is working, both match commands should return something like DejaVuSans.ttf.