How to Install Fonts on RHEL via the Command Line
Introduction
Whether you’re customizing your desktop environment or ensuring a specific application has the resources it needs, installing new fonts is a common system administration task. On Red Hat Enterprise Linux (RHEL) and similar distributions, this process can be handled efficiently directly from the command line.
This guide provides two distinct methods for installing fonts: for a single user account and for all users system-wide.
Method 1: Installing Fonts for the Current User
This approach installs a font exclusively for your user account, without affecting other users on the system. It does not require administrative privileges.
Create a local font directory: The standard location for user-specific fonts is
~/.local/share/fonts
. Create this directory if it doesn’t already exist.mkdir -p ~/.local/share/fonts/
Copy the font file: Copy your font file (e.g., a
.ttf
or.otf
file) into the newly created directory.cp /path/to/your/font.ttf ~/.local/share/fonts/
Update the font cache: Run the
fc-cache
command to rebuild the system’s font cache, making the new font available to applications.fc-cache -fv
How It Works
mkdir -p ~/.local/share/fonts/
: This command creates thefonts
directory inside~/.local/share
. The-p
flag ensures that any necessary parent directories are created without generating an error if they already exist.cp /path/to/your/font.ttf ...
: This standard copy command places your font file in the correct location for user-specific fonts.fc-cache -fv
: This is the crucial final step. Thefc-cache
utility scans font directories and builds a cache of information about available fonts. Applications use this cache to quickly locate and render fonts.- The
-f
flag forces a full rescan and rebuild of the cache. - The
-v
flag enables verbose output, showing the progress of the command.
- The
Method 2: Installing Fonts System-Wide (For All Users)
To make a font available to every user on the system, you must place it in a system-wide directory. This action requires superuser (root) privileges.
Create a system font directory: A common location for manually installed system-wide fonts is
/usr/local/share/fonts
.sudo mkdir -p /usr/local/share/fonts/
Copy the font file: Using
sudo
, copy the font file into the system directory.sudo cp /path/to/your/font.ttf /usr/local/share/fonts/
Update the font cache: Finally, rebuild the system font cache with
sudo
.sudo fc-cache -fv
Key Differences
The primary difference from the user-specific method is the directory path (/usr/local/share/fonts
instead of ~/.local/share/fonts
) and the use of sudo
for all commands, as you are modifying system-level directories.
Verifying the Installation
After installing the font and updating the cache, you can verify that the system recognizes it using the fc-list
command combined with grep
.
Replace "FontName"
with the name of the font you installed.
fc-list | grep "FontName"
If the installation was successful, this command will return the path and details of the newly installed font.
Conclusion
Installing fonts on a RHEL system from the command line is a straightforward process. By copying the font files to the appropriate directory (~/.local/share/fonts
for a single user or /usr/local/share/fonts
for all users) and updating the cache with fc-cache
, you can quickly make new typefaces available to your system and its applications.