How to look up dictionary via command line on Linux

If you need to look up a word definition, you can refer to any online dictionary on the web. However, what if you don't have X11 installed on your Linux, or have no network connectivity? Then you may have to resort to offline command-line dictionary tools if there is one.

One way to look up dictionary via command line on Linux is to locally set up dictd, which is a dictionary database server. dictd uses Dictionary Server Protocol (DICT) to allow a client to look up dictionary definitions from dictionary databases over network. If dictd daemon is set up on localhost, you can access dictionary offline. dictd comes with a command-line client.

To install dictd on Ubuntu or Debian:

$ sudo apt-get install dictd

After installing dict, you also need to install dictionaries to use. If you install any new dictionary, dictd will automatically get restarted to reload its dictionary databases.

$ sudo apt-get install dict-gcide (English dictionary)
$ sudo apt-get install dict-moby-thesaurus (Thesaurus dictionary)

There are many other multi-language dictionaries available. For example:

sudo apt-cache search "dict package"
dict-freedict-eng-ara - Dict package for English-Arabic Freedict dictionary
dict-freedict-eng-cro - Dict package for English-Croatian Freedict dictionary
dict-freedict-eng-cze - Dict package for English-Czech Freedict dictionary
dict-freedict-eng-deu - Dict package for English-German Freedict dictionary
dict-freedict-eng-fra - Dict package for English-French Freedict dictionary
dict-freedict-eng-hin - Dict package for English-Hindi Freedict dictionary
dict-freedict-eng-hun - Dict package for English-Hungarian Freedict dictionary
dict-freedict-eng-iri - Dict package for English-Irish Freedict dictionary
dict-freedict-eng-ita - Dict package for English-Italian Freedict dictionary
dict-freedict-eng-lat - Dict package for English-Latin Freedict dictionary
dict-freedict-eng-nld - Dict package for English-Dutch Freedict dictionary
dict-freedict-eng-por - Dict package for English-Portuguese Freedict dictionary
dict-freedict-eng-rom - Dict package for English-Romanian Freedict dictionary
dict-freedict-eng-rus - Dict package for English-Russian Freedict dictionary
dict-freedict-eng-scr - Dict package for English-Serbo-Croat Freedict dictionary
dict-freedict-eng-spa - Dict package for English-Spanish Freedict dictionary
dict-freedict-eng-swa - Dict package for English-Swahili Freedict dictionary
dict-freedict-eng-swe - Dict package for English-Swedish Freedict dictionary
. . .

Now you can use a command-line client called dict to access the dictd server for dictionary lookup.

To check if dictd server is running, and what dictionary databases are available, run the following. In this example, two dictionaries are available.

$ dict -I
  dictd 1.12.0/rf on Linux 3.2.0-29-generic-pae
  On my_host: up 95.000, 2 forks (75.8/hour)
  
  Database      Headwords         Index          Data  Uncompressed
  gcide              203645       3859 kB         12 MB         38 MB
  moby-thesaurus      30263        528 kB         10 MB         28 MB

To look up a word definition using a particular dictionary (e.g., gcide):

$ dict -d gcide [word]

If you do not specify any database using "-d" option, dictd will search for all available databases and return all matched definitions.

For your convenience, you can set up aliases to look up a particular database for word definition. For example, as a command-line thesaurus, you add the following alias to ~/.bashrc

alias thrus='dict -d moby-thesaurus'
$ thrus cryptography
1 definition found

From Moby Thesaurus II by Grady Ward, 1.0 [moby-thesaurus]:

  48 Moby Thesaurus words for "cryptography":
     cipher, code, coded message, coup de plume, criticism,
     cryptanalysis, cryptoanalysis, cryptoanalytics, cryptogram,
     cryptograph, cryptographer, cryptology, diagnostics, engrossment,
     epigraphy, exegetics, hermeneutics, ink spilling, inkslinging,
     inscription, invisible ink, lettering, lexicography,
     literary criticism, macrography, metoposcopy, micrography,
     oneirology, paleography, pathognomy, pen, pen-and-ink,
     pencil driving, physiognomics, physiognomy, scrivenery, scrivening,
     secret language, secret writing, semeiology, semeiotics,
     sympathetic ink, symptomatology, textual criticism, tropology,
     typewriting, typing, writing

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

One thought on “How to look up dictionary via command line on Linux

  1. I just wish to give a huge thumbs up for the good information you have here on this post. I am also writing blog about daily Linux issues I face. Keep well.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *