Last updated on November 28, 2020 by Dan Nanni
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 called dict
.
dictd
on Linuxdictd
on Ubuntu or Debian$ sudo apt-get install dictd
After installing dictd
, 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 . . .
dictd
on CentOS, RHEL or Fedora$ sudo yum install dictd dict
Similar to Ubuntu/Debian-based systems, you can also install any necessary dictionaries with yum
command.
dictd
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'
Then you can look up synonyms/antonyms of a word using:
$ 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
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean