Skip to content

Instantly share code, notes, and snippets.

@jmrashed
Created July 28, 2023 00:08
Show Gist options
  • Save jmrashed/51eacae2095eca0bfa4769f1b8add20c to your computer and use it in GitHub Desktop.
Save jmrashed/51eacae2095eca0bfa4769f1b8add20c to your computer and use it in GitHub Desktop.
Install Fonts in Ubuntu Using Terminal
Prepare the Font Files:
Before proceeding, make sure you have all the font files (in .ttf or .otf format) you want to install. Place all these font files in a single directory, for example, create a folder named "MyFonts" and place the font files inside it.
Open Terminal:
Press `Ctrl + Alt + T` to open a terminal window.
Navigate to the Font Directory:
Use the cd command to navigate to the directory where you placed all the font files. For example, if you placed them in the "MyFonts" folder under your home directory, use the following command:
`cd ~/MyFonts`
Install the Fonts Using a Loop:
Use a for loop to iterate through all the font files in the directory and install them one by one. The sudo cp command is used to copy each font file to the system's font directory, and fc-cache is used to update the font cache after copying each font.
```bash
for font_file in *.ttf *.otf; do
sudo cp "$font_file" /usr/share/fonts/truetype/
sudo fc-cache -f -v
done
```
This loop will install all the .ttf and .otf font files in the directory to your Ubuntu system, and they will be available for use in various applications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment