How to Create An Online Dictionary with Dico in Linux

A photograph of a page from a paper dictionary.

Dico is a modern implementation of the traditional DICT protocol. It aims to create a fully modular dictionary server software that you can host almost anywhere. This tutorial shows how you can install and use Dico as your local “online” dictionary server in Linux.

Alternative: you can also install the SDCV dictionary app in the Linux terminal.

What Is an Online Dictionary and Why Use One?

Dictionary (DICT) servers are Internet programs that load and serve word definitions from an internal file. Unlike web dictionaries, DICT servers can be incredibly lightweight and flexible to changes, making it attractive for users that want to maintain their own dictionary at home.

A terminal window showing a dictionary entry from a DICT server.

Aside from that, modern DICT servers are also fully compatible with GNU Emacs, so you can create a Dico server, link it with GNU Emacs and load word definitions from inside the editor.

An Emacs window showing its integration with the DICT protocol.

Lastly, DICT servers are also simple and easy to implement. Hosting one can be a good and fun starting point if you are a beginner at deploying Internet services.

Good to know: once you have your feet wet deploying server software, a good next step would be hosting your own Email server.

Installing GNU Dico

  1. Run the following command to obtain GNU Dico’s dependencies.
sudo apt install wget gcc make m4 m4-doc python3 libltdl-dev libdico2 zlib1g-dev
A terminal window showing the dependencies for GNU Dico.
  1. Download the GNU Dico source archive from the developer’s website:
A terminal window showing the download process for GNU Dico.
  1. Extract the program archive in your current working directory:
tar xvJf ./dico-2.11.tar.xz
A terminal window showing the extraction process for GNU Dico.
  1. Go inside the program’s directory.
cd ./dico-2.11
  1. Run Dico’s initial configuration script:
A terminal window showing the configuration process for the GNU Dico source.
  1. Start the program’s compilation process:
A terminal window showing the compilation process for GNU Dico.
  1. Install the program in your system’s “/usr/local/bin” directory:
sudo make install
A terminal window showing the copying process of the GNU Dico binary.

Obtaining an Online Dictionary Database

Once you have installed the GNU Dico binary, download a dictionary database. It contains all the definitions that the program will serve once it is up and running.

One of the easiest ways to get a dictionary database is through the GNU Collaborative International Dictionary of English (GCIDE). It’s a free and open source collection of English words and definitions that spans back to 1913.

A terminal window showing a segment of  the GCIDE index.
  1. Download GCIDE from the maintainer’s website:
A terminal window showing the GCIDE download process.
  1. Extract the archive using tar:
tar xvJf ./gcide-0.53.tar.xz
A terminal window showing the GCIDE extraction process.
  1. Copy the archive to your machine’s “/usr/local/share/” directory:
sudo cp -rv ./gcide-0.53 /usr/local/share/
A terminal window showing the GCIDE database being copied to the share directory.

Configuring and Running GNU Dico

At this point, your system has a basic GNU Dico installation. For example, you can run dico in your terminal, and it will give you a basic prompt.

A terminal window showing a basic GNU Dico console.

However, you still need to configure some of its settings to make it work properly for your machine.

  1. Go to your “/usr/local/etc” directory:
cd /usr/local/etc/
A terminal window showing the current working directory to /usr/local/etc.
  1. Create the GNU Dico configuration file:
sudo touch ./dicod.conf
  1. Open your new configuration file using your favorite text editor:
sudo nano ./dicod.conf
  1. Add the following lines of code, a version of the default conf file that I have modified to work with GCIDE.
capability (mime,xversion);
timing yes;
pidfile /var/run/dicod/;
module-load-path ("/usr/local/lib/dico");
load-module gcide;
database {
   name "gcide";
   handler "gcide dbdir=/usr/local/share/gcide-0.53 suppress-pr";
   languages-from "en";
   languages-to "en";
user dicod;
max-children 18;
inactivity-timeout 5;
server-info <<EOT
This is a Dico server.
  1. Save your configuration file by pressing Ctrl + O, then Ctrl + X.
A terminal window showing a basic GNU Dico configuration file.
  1. Test your GNU Dico installation:
sudo dicod --foreground
  1. Run an instance of the Dico console program by running dico on a separate terminal.
A terminal window showing the basic GNU Dico console.
  1. Type .open localhost to connect to the local Dico instance.
A terminal window showing a localhost connection with GNU Dico.
  1. Test your new Dico server by sending any English word to the console prompt.
A terminal window showing a sample definition from the local GNU Dico instance.

Configure GNU Dico to Autostart During Bootup

You can create a systemd service for GNU Dico, allowing you to easily manage your online dictionary and run it without a dedicated command line.

  1. Create a systemd service file:
touch personal-dicod.service
  1. Open your new service file using your favorite text editor:
nano personal-dicod.service
A terminal window showing an empty service file.
  1. Add the following lines of code inside your service file:
Description=A basic GNU Dico Daemon Service
ExecStart=/usr/local/bin/dicod -f --stderr
A terminal window showing a basic SystemD service file.
  1. Copy your service file to the systemd services directory:
sudo cp ./personal-dicod.service /etc/systemd/system/
Install Dico Dictionary Linux 21 Copy Service File To Systemd Directory
  1. Create the directory where dicod will store its pidfile:
sudo mkdir /run/dicod
sudo chown -R dicod:dicod /run/dicod
A terminal window showing the /run/dicod file with proper permissions.
  1. Reload systemd to apply your new configuration:
sudo systemctl daemon-reload
  1. Start your GNU Dico service by running the following commands:
sudo systemctl enable personal-dicod.service
sudo systemctl start personal-dicod.service
Install Dico Dictionary Linux 23 Enable Systemd Daemon

Tip: if you intend on running GNU Dico on a public network, secure your Linux server from malicious actors.

Aside from using the GNU Dico console, you can also integrate your new dictionary server to external applications. For example, easily link your Dico server with GNU Emacs by using the “dictionary.el” package.

  1. To install the package, press Alt + X, then type “package-install.”
An Emacs window showing the "Install Package:" prompt.
  1. Type “dictionary” in the command buffer prompt.
An Emacs window showing the dictionary.el package install.
  1. After that, press Alt + X, then type “customize-variable.”
An Emacs window showing the customize-variable function.
  1. Type “dictionary-server” in the new buffer prompt.
An Emacs window showing how to customize the dictionary-server variable.
  1. Select the text box beside the “Dictionary Server” label and type localhost.
An Emacs window showing the new localhost variable for dictionary.el.
  1. Click “Apply and Save” to commit your new setting.
An Emacs window showing the "Apply and Save" button and comitting the new setting.
  1. You can search your dictionary server by pressing Alt + X, then typing “dictionary-search” in the command buffer prompt.
An Emacs window showing an example definition from inside Emacs.

FYI: Emacs is more than just a dictionary browser. Learn how you can also use it to create beautiful LaTeX documents without knowing any TeX code.

Frequently Asked Questions

Dicod immediately terminates whenever I run it.

While this can be due to a number of issues, the most common cause for this is a misconfigured PID file. You can fix this by making sure that the dicod user and group exists in your system: sudo groupadd dicod && sudo useradd -s /usr/sbin/nologin -d /var/lib/dicod -g dicod dicod.

Also double check your “dicod.conf” file for any additional errors by running: dicod -t.

Is it possible to use a different online dictionary with GNU Dico?

Yes. However, you also need to make sure that Dico is loading the new dictionary’s module and database block in its “dicod.conf” file. For example, to use the database, you need to download a copy of its database files and load its module in your Dico configuration file.

The dictionary.el package does not exist in my Emacs repository.

You can add the dictionary.el package by including the MELPA repositories in your init.el file. For example, the following line adds the “MELPA Stable” branch to your Emacs installation: (add-to-list 'package-archives '("melpa-stable" . "") t).

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

Ramces Red
Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox