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:
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-moby-thesaurus (Thesaurus dictionary)
There are many other multi-language dictionaries available. For example:
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.
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):
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'
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
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.