{ "created": "2015-12-20T19:56:43Z", "hierarchy": [ { "name": "ROOT", "type": "folder", "uri": "/ROOT" }, { "name": "Dictd and Dictionaries on Linux", "type": "article", "uri": "Dictd_and_Dictionaries_on_Linux" } ], "html": "\n\n \n \n \n \n\n \n \n\n \n \n \n \n \n\n Dictd and Dictionaries on Linux\n\n \n \n \n \n
\n
\n \n
\n
\n \n \n\n\n

Dictd and Dictionaries on Linux

\n\n

[TOC]

\n

On the command line, it is possible to use curl to get a dictionary\nreference. We can first list all the dictionaries available at\ndict.org like so:

\n
curl dict://dict.org/show:db\n
\n

This lists all available dictionaries and their shortnames:

\n
gcide "The Collaborative International Dictionary of English v.0.48"  \nwn "WordNet (r) 2.     \nmoby-thes "Moby Thesaurus II by Grady Ward, 1.0"  \nelements "Elements database 20001107"  \nvera "Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)"  \njargon "Jargon File (4.3.1, 29 Jun 2001)"  \nfoldoc "The Free On-line Dictionary of Computing (27 SEP 03)"  \neaston "Easton's 1897 Bible Dictionary"  \nhitchcock "Hitchcock's Bible Names Dictionary (late 1800's)"  \nbouvier "Bouvier's Law Dictionary, Revised 6th Ed (1856)"  \ndevils "THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)"  \nworld02 "CIA World Factbook 2002"  \n.  \n.  \n.  \neng-fra "English-French Freedict Dictionary"\n
\n

To look up a word or phrase from a certain dictionary, issue:

\n
curl dict://dict.org/d:word_goes_here:dictionary_short_name_here\n
\n

For instance, I’ll attempt to look up India in the CIA World FactBook\n(2002 edition):

\n
curl dict://dict.org/d:India:world02 > India.Reference.txt\n
\n

And obtain this (partial dump):

\n
20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686 <auth.mime> <62887065.988.1256582810@miranda.org>  \n250 ok  \n150 1 definitions retrieved  \n151 "India" world02 "CIA World Factbook 2002"  \nIndia  \n   \nIntroduction India  \n------------------  \nBackground: The Indus Valley civilization, one   \nof the oldest in the world, goes  \nback at least 5,000 years. Aryan  \ntribes from the northwest invaded  \nabout 1500 B.C.; their merger with  \nthe earlier inhabitants created the   \nclassical Indian culture. Arab  \nincursions starting in the 8th  \ncentury and Turkish in 12th were  \nfollowed by European traders  \nbeginning in the late 15th century.  \nBy the 19th century, Britain had   \nassumed political control of  \nvirtually all Indian lands.\n
\n

Offline Dictionaries

\n

The example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there’s a tool for precisely this\npurpose on Linux called dict and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.

\n

The utility is split into two tools: dictd (the server daemon) and\ndict (the client application.)

\n

The dict client, by itself, can search the resources at dict.org if\nyou don’t want to install the server. What follows is a guide to\ninstalling the dictd daemon and configuring the client app to look at\n‘itself’ (i.e. localhost)

\n

Step 1: Obtain and install dict

\n
wget ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz\n
\n

Where 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the typical installation\ninstructions to compile this from\nsource.

\n

Note: You might get compiler warnings when running make against\nlower version numbers since this is a\nbug.

\n

A few things:

\n\n

Step 2: Obtain and set up dictionaries

\n

The dictionary or reference files the dictd daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster’s 1913 dictionary (which is in public domain).

\n
wget ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz\n
\n

Once you untar the archive, place the two files web1913.dict.dz and\nweb1913.index in a convenient location. I placed mine at\n/usr/share/dictionaries. Make sure these are readable!

\n
chmod a+r web1913.dict.dz web1913.index\n
\n

You can obtain other dictionaries by perusing the FTP site you got the\nWebster’s dictionary from

\n

Note: /usr/share/dict is not an appropriate location!\nlinux.words is the file used by the passwd command, for instance, to\ndetermine weak passwords.

\n

Step 3: Configure dict

\n

You now need to create two configuration files for the dict server and\nclient: dictd.conf and dict.conf respectively. These need to go in\n/usr/local/etc

\n

Configure dictd server

\n

dictd.conf will contain references to the database(s) from Step 2.

\n
database web1913 { data "/usr/share/dictionary/web1913.dict.dz" \n                   index "/usr/share/dictionary/web1913.index" }\n
\n

If you installed another reference database from the FTP\nsite in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:

\n
database elements { data "/usr/share/dictionary/elements.dict.dz"   \n                   index "/usr/share/dictionary/elements.index" }\n
\n

After this stage, start the dictd server

\n

  /usr/local/sbin/dictd start

\n

Test your installation with something

\n

 dictd --test perspicacious

\n

Configure dict client

\n

dict.conf can contain a single server or a list of servers which have\nthe dictd daemon running. In this example, we’ll use our own machine

\n

 server localhost

\n

And that’s it! Test this with

\n

 dict surreptitious

\n

Other notes

\n

You might need an init script if dict word does not work.

\n
DICTD=/usr/local/bin/dictd\n\n# DICTD_OPTIONS="-put -command_line -options -for -dictd -here"\nDICTD_OPTIONS=""\nDICTD_PID_FILE=/etc/dictd.pid\n\ncase "$1" in\n    'start')\n        if [ -x $DICTD ]; then\n            echo "dictd starting."\n            $DICTD $DICTD_OPTIONS\n        else\n            echo "dictd.init: cannot find $DICTD or it's not executable"\n        fi  \n    ;;  \n    'stop')\n        if [ ! -f $DICTD_PID_FILE ]; then\n            exit 0\n        fi  \n        dictdpid=`cat $DICTD_PID_FILE`\n        if [ "$dictdpid" -gt 0 ]; then\n            echo "Stopping the dictd server."\n            kill -15 $dictdpid 2>&1 > /dev/null\n        fi  \n        rm -f $DICTD_PID_FILE\n    ;;  \n    *)\n        echo "Usage: dictd.init { start | stop }"\n    ;;\nesac\nexit 0\n

To Do

\n\n\n\n
\n \n
\n \n \n \n \n \n\n", "id": "3af3682b-3eda-56da-bd49-b2c4ac90a290", "modified": "2022-06-13T23:23:48Z", "revisions": [ { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2022-06-13T23:23:48Z", "id": "6be928c4c8de048934c03e3c61539c9ceec7d59a", "shortId": "6be928c4", "subject": "Update config.yml", "content": "[TOC]\n\nOn the command line, it is possible to use `curl` to get a dictionary\nreference. We can first list all the dictionaries available at\n[dict.org](http://dict.org) like so:\n\n curl dict://dict.org/show:db\n\nThis lists all available dictionaries and their shortnames:\n\n gcide \"The Collaborative International Dictionary of English v.0.48\" \n wn \"WordNet (r) 2.    \n moby-thes \"Moby Thesaurus II by Grady Ward, 1.0\" \n elements \"Elements database 20001107\" \n vera \"Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)\" \n jargon \"Jargon File (4.3.1, 29 Jun 2001)\" \n foldoc \"The Free On-line Dictionary of Computing (27 SEP 03)\" \n easton \"Easton's 1897 Bible Dictionary\" \n hitchcock \"Hitchcock's Bible Names Dictionary (late 1800's)\" \n bouvier \"Bouvier's Law Dictionary, Revised 6th Ed (1856)\" \n devils \"THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)\" \n world02 \"CIA World Factbook 2002\" \n . \n . \n . \n eng-fra \"English-French Freedict Dictionary\"\n\nTo look up a word or phrase from a certain dictionary, issue:\n\n curl dict://dict.org/d:word_goes_here:dictionary_short_name_here\n\nFor instance, I'll attempt to look up India in the CIA World FactBook\n(2002 edition):\n\n curl dict://dict.org/d:India:world02 > India.Reference.txt\n\nAnd obtain this (partial dump):\n\n 20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686  <62887065.988.1256582810@miranda.org> \n 250 ok \n 150 1 definitions retrieved \n 151 \"India\" world02 \"CIA World Factbook 2002\" \n India \n   \n Introduction India \n ------------------ \n Background: The Indus Valley civilization, one  \n of the oldest in the world, goes \n back at least 5,000 years. Aryan \n tribes from the northwest invaded \n about 1500 B.C.; their merger with \n the earlier inhabitants created the  \n classical Indian culture. Arab \n incursions starting in the 8th \n century and Turkish in 12th were \n followed by European traders \n beginning in the late 15th century. \n By the 19th century, Britain had  \n assumed political control of \n virtually all Indian lands.\n\nOffline Dictionaries\n--------------------\n\nThe example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there's a tool for precisely this\npurpose on Linux called [**dict**](http://www.dict.org/bin/Dict) and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.\n\nThe utility is split into two tools: `dictd` (the server daemon) and\n`dict` (the client application.)\n\nThe `dict` client, by itself, can search the resources at dict.org if\nyou don't want to install the server. What follows is a guide to\ninstalling the `dictd` daemon and configuring the client app to look at\n'itself' (i.e. localhost)\n\n#### Step 1: Obtain and install dict\n\n wget ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz\n\nWhere 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the [typical installation\ninstructions](ftp://ftp.dict.org/dict/INSTALL) to compile this from\nsource.\n\n**Note**: You might get compiler warnings when running `make` against\nlower version numbers [since this is a\nbug](http://bugs.gentoo.org/81211).\n\nA few things:\n\n* If you did not use `--prefix` when running `configure`, the path to\n `dictd` (server) should be `/usr/local/sbin`\n* Configuration files for client and server will be in\n `/usr/local/etc`\n\n#### Step 2: Obtain and set up dictionaries\n\nThe dictionary or reference files the `dictd` daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster's 1913 dictionary (which is in public domain).\n\n wget ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz\n\nOnce you untar the archive, place the two files `web1913.dict.dz` and\n`web1913.index` in a convenient location. I placed mine at\n`/usr/share/dictionaries`. Make sure these are readable!\n\n chmod a+r web1913.dict.dz web1913.index\n\nYou can obtain other dictionaries by perusing [the FTP site you got the\nWebster's dictionary from](ftp://ftp.dict.org/dict/pre/)\n\n**Note**: `/usr/share/dict` is *not* an appropriate location!\n`linux.words` is the file used by the `passwd` command, for instance, to\ndetermine weak passwords.\n\n#### Step 3: Configure dict\n\nYou now need to create two configuration files for the dict server and\nclient: `dictd.conf` and `dict.conf` respectively. These need to go in\n`/usr/local/etc`\n\nConfigure dictd server\n----------------------\n\n`dictd.conf` will contain references to the database(s) from Step 2.\n\n database web1913 { data \"/usr/share/dictionary/web1913.dict.dz\" \n                    index \"/usr/share/dictionary/web1913.index\" }\n\nIf you installed another reference database from [the FTP\nsite](ftp://ftp.dict.org/dict/pre/) in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:\n\n database elements { data \"/usr/share/dictionary/elements.dict.dz\"  \n                    index \"/usr/share/dictionary/elements.index\" }\n\nAfter this stage, start the dictd server\n\n`  /usr/local/sbin/dictd start`\n\nTest your installation with something\n\n` dictd --test perspicacious`\n\nConfigure dict client\n---------------------\n\n`dict.conf` can contain a single server or a list of servers which have\nthe `dictd` daemon running. In this example, we'll use our own machine\n\n` server localhost`\n\nAnd that's it! Test this with\n\n` dict surreptitious`\n\nOther notes\n-----------\n\nYou might need an init script if `dict word` does not work.\n\n```bash\nDICTD=/usr/local/bin/dictd\n\n# DICTD_OPTIONS=\"-put -command_line -options -for -dictd -here\"\nDICTD_OPTIONS=\"\"\nDICTD_PID_FILE=/etc/dictd.pid\n\ncase \"$1\" in\n 'start')\n if [ -x $DICTD ]; then\n echo \"dictd starting.\"\n $DICTD $DICTD_OPTIONS\n else\n echo \"dictd.init: cannot find $DICTD or it's not executable\"\n fi \n ;; \n 'stop')\n if [ ! -f $DICTD_PID_FILE ]; then\n exit 0\n fi \n dictdpid=`cat $DICTD_PID_FILE`\n if [ \"$dictdpid\" -gt 0 ]; then\n echo \"Stopping the dictd server.\"\n kill -15 $dictdpid 2>&1 > /dev/null\n fi \n rm -f $DICTD_PID_FILE\n ;; \n *)\n echo \"Usage: dictd.init { start | stop }\"\n ;;\nesac\nexit 0\n```\n\n### To Do\n\n* Add information on doing this securely (i.e. dictd should use only\n one port in iptables)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-27T07:27:56Z", "id": "5a5b1a32f41081d062ab86f8869a961bcad79668", "shortId": "5a5b1a32", "subject": "Fix Markdown conversion\n\nSaw half a season of The Office\n", "content": "[TOC]\n\nOn the command line, it is possible to use `curl` to get a dictionary\nreference. We can first list all the dictionaries available at\n[dict.org](http://dict.org) like so:\n\n curl dict://dict.org/show:db\n\nThis lists all available dictionaries and their shortnames:\n\n gcide \"The Collaborative International Dictionary of English v.0.48\" \n wn \"WordNet (r) 2.    \n moby-thes \"Moby Thesaurus II by Grady Ward, 1.0\" \n elements \"Elements database 20001107\" \n vera \"Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)\" \n jargon \"Jargon File (4.3.1, 29 Jun 2001)\" \n foldoc \"The Free On-line Dictionary of Computing (27 SEP 03)\" \n easton \"Easton's 1897 Bible Dictionary\" \n hitchcock \"Hitchcock's Bible Names Dictionary (late 1800's)\" \n bouvier \"Bouvier's Law Dictionary, Revised 6th Ed (1856)\" \n devils \"THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)\" \n world02 \"CIA World Factbook 2002\" \n . \n . \n . \n eng-fra \"English-French Freedict Dictionary\"\n\nTo look up a word or phrase from a certain dictionary, issue:\n\n curl dict://dict.org/d:word_goes_here:dictionary_short_name_here\n\nFor instance, I'll attempt to look up India in the CIA World FactBook\n(2002 edition):\n\n curl dict://dict.org/d:India:world02 > India.Reference.txt\n\nAnd obtain this (partial dump):\n\n 20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686  <62887065.988.1256582810@miranda.org> \n 250 ok \n 150 1 definitions retrieved \n 151 \"India\" world02 \"CIA World Factbook 2002\" \n India \n   \n Introduction India \n ------------------ \n Background: The Indus Valley civilization, one  \n of the oldest in the world, goes \n back at least 5,000 years. Aryan \n tribes from the northwest invaded \n about 1500 B.C.; their merger with \n the earlier inhabitants created the  \n classical Indian culture. Arab \n incursions starting in the 8th \n century and Turkish in 12th were \n followed by European traders \n beginning in the late 15th century. \n By the 19th century, Britain had  \n assumed political control of \n virtually all Indian lands.\n\nOffline Dictionaries\n--------------------\n\nThe example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there's a tool for precisely this\npurpose on Linux called [**dict**](http://www.dict.org/bin/Dict) and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.\n\nThe utility is split into two tools: `dictd` (the server daemon) and\n`dict` (the client application.)\n\nThe `dict` client, by itself, can search the resources at dict.org if\nyou don't want to install the server. What follows is a guide to\ninstalling the `dictd` daemon and configuring the client app to look at\n'itself' (i.e. localhost)\n\n#### Step 1: Obtain and install dict\n\n wget ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz\n\nWhere 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the [typical installation\ninstructions](ftp://ftp.dict.org/dict/INSTALL) to compile this from\nsource.\n\n**Note**: You might get compiler warnings when running `make` against\nlower version numbers [since this is a\nbug](http://bugs.gentoo.org/81211).\n\nA few things:\n\n* If you did not use `--prefix` when running `configure`, the path to\n `dictd` (server) should be `/usr/local/sbin`\n* Configuration files for client and server will be in\n `/usr/local/etc`\n\n#### Step 2: Obtain and set up dictionaries\n\nThe dictionary or reference files the `dictd` daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster's 1913 dictionary (which is in public domain).\n\n wget ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz\n\nOnce you untar the archive, place the two files `web1913.dict.dz` and\n`web1913.index` in a convenient location. I placed mine at\n`/usr/share/dictionaries`. Make sure these are readable!\n\n chmod a+r web1913.dict.dz web1913.index\n\nYou can obtain other dictionaries by perusing [the FTP site you got the\nWebster's dictionary from](ftp://ftp.dict.org/dict/pre/)\n\n**Note**: `/usr/share/dict` is *not* an appropriate location!\n`linux.words` is the file used by the `passwd` command, for instance, to\ndetermine weak passwords.\n\n#### Step 3: Configure dict\n\nYou now need to create two configuration files for the dict server and\nclient: `dictd.conf` and `dict.conf` respectively. These need to go in\n`/usr/local/etc`\n\nConfigure dictd server\n----------------------\n\n`dictd.conf` will contain references to the database(s) from Step 2.\n\n database web1913 { data \"/usr/share/dictionary/web1913.dict.dz\" \n                    index \"/usr/share/dictionary/web1913.index\" }\n\nIf you installed another reference database from [the FTP\nsite](ftp://ftp.dict.org/dict/pre/) in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:\n\n database elements { data \"/usr/share/dictionary/elements.dict.dz\"  \n                    index \"/usr/share/dictionary/elements.index\" }\n\nAfter this stage, start the dictd server\n\n`  /usr/local/sbin/dictd start`\n\nTest your installation with something\n\n` dictd --test perspicacious`\n\nConfigure dict client\n---------------------\n\n`dict.conf` can contain a single server or a list of servers which have\nthe `dictd` daemon running. In this example, we'll use our own machine\n\n` server localhost`\n\nAnd that's it! Test this with\n\n` dict surreptitious`\n\nOther notes\n-----------\n\nYou might need an init script if `dict word` does not work.\n\n```bash\nDICTD=/usr/local/bin/dictd\n\n# DICTD_OPTIONS=\"-put -command_line -options -for -dictd -here\"\nDICTD_OPTIONS=\"\"\nDICTD_PID_FILE=/etc/dictd.pid\n\ncase \"$1\" in\n 'start')\n if [ -x $DICTD ]; then\n echo \"dictd starting.\"\n $DICTD $DICTD_OPTIONS\n else\n echo \"dictd.init: cannot find $DICTD or it's not executable\"\n fi \n ;; \n 'stop')\n if [ ! -f $DICTD_PID_FILE ]; then\n exit 0\n fi \n dictdpid=`cat $DICTD_PID_FILE`\n if [ \"$dictdpid\" -gt 0 ]; then\n echo \"Stopping the dictd server.\"\n kill -15 $dictdpid 2>&1 > /dev/null\n fi \n rm -f $DICTD_PID_FILE\n ;; \n *)\n echo \"Usage: dictd.init { start | stop }\"\n ;;\nesac\nexit 0\n```\n\n### To Do\n\n* Add information on doing this securely (i.e. dictd should use only\n one port in iptables)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-21T02:30:47Z", "id": "3f2c54b1d767218fcb4855fbac306b015afaf551", "shortId": "3f2c54b1", "subject": "Incremental\n", "content": "When connected to the internet, there exist many ways to look up a word.\n[Answers.com](http://answers.com),\n[Dictionary.com](http://dictionary.com) are all valid resources if using\na browser. Command line checks (I find) are far faster and there exist\nways to cache a dictionary for really quick lookups if you're on OS X or\nLinux (Cygwin on Windows). And it does not stop with dictionaries: you\ncan add periodic table listings, Wikipedia, the CIA world factbook, the\ncomputer jargon dictionary, WebMD, and many more resources.\n\n### Command-line tricks\n\nOn the command line, it is possible to use `curl` to get a dictionary\nreference. We can first list all the dictionaries available at\n[dict.org](http://dict.org) like so:\n\n` curl `[`dict://dict.org/show:db`](dict://dict.org/show:db)\n\nThis lists all available dictionaries and their shortnames:\n\n` gcide \"The Collaborative International Dictionary of English v.0.48\"` \n` wn \"WordNet (r) 2.   ` \n` moby-thes \"Moby Thesaurus II by Grady Ward, 1.0\"` \n` elements \"Elements database 20001107\"` \n` vera \"Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)\"` \n` jargon \"Jargon File (4.3.1, 29 Jun 2001)\"` \n` foldoc \"The Free On-line Dictionary of Computing (27 SEP 03)\"` \n` easton \"Easton's 1897 Bible Dictionary\"` \n` hitchcock \"Hitchcock's Bible Names Dictionary (late 1800's)\"` \n` bouvier \"Bouvier's Law Dictionary, Revised 6th Ed (1856)\"` \n` devils \"THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)\"` \n` world02 \"CIA World Factbook 2002\"` \n` .` \n` .` \n` .` \n` eng-fra \"English-French Freedict Dictionary\"`\n\nTo look up a word or phrase from a certain dictionary, issue:\n\n`curl `[`dict://dict.org/d:word_goes_here:dictionary_short_name_here`](dict://dict.org/d:word_goes_here:dictionary_short_name_here)\n\nFor instance, I'll attempt to look up India in the CIA World FactBook\n(2002 edition):\n\n`curl `[`dict://dict.org/d:India:world02`](dict://dict.org/d:India:world02)` > India.Reference.txt`\n\nAnd obtain this (partial dump):\n\n` 20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686 `` <62887065.988.1256582810@miranda.org>` \n` 250 ok` \n` 150 1 definitions retrieved` \n` 151 \"India\" world02 \"CIA World Factbook 2002\"` \n` India` \n` ` \n` Introduction India` \n` ------------------` \n` Background: The Indus Valley civilization, one ` \n` of the oldest in the world, goes` \n` back at least 5,000 years. Aryan` \n` tribes from the northwest invaded` \n` about 1500 B.C.; their merger with` \n` the earlier inhabitants created the ` \n` classical Indian culture. Arab` \n` incursions starting in the 8th` \n` century and Turkish in 12th were` \n` followed by European traders` \n` beginning in the late 15th century.` \n` By the 19th century, Britain had ` \n` assumed political control of` \n` virtually all Indian lands.`\n\n### Offline Dictionaries\n\nThe example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there's a tool for precisely this\npurpose on Linux called [**dict**](http://www.dict.org/bin/Dict) and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.\n\nThe utility is split into two tools: `dictd` (the server daemon) and\n`dict` (the client application.)\n\nThe `dict` client, by itself, can search the resources at dict.org if\nyou don't want to install the server. What follows is a guide to\ninstalling the `dictd` daemon and configuring the client app to look at\n'itself' (i.e. localhost)\n\n#### Step 1: Obtain and install dict\n\n`  wget `[`ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz`](ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz)\n\nWhere 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the [typical installation\ninstructions](ftp://ftp.dict.org/dict/INSTALL) to compile this from\nsource.\n\n**Note**: You might get compiler warnings when running `make` against\nlower version numbers [since this is a\nbug](http://bugs.gentoo.org/81211).\n\nA few things:\n\n- If you did not use `--prefix` when running `configure`, the path to\n `dictd` (server) should be `/usr/local/sbin`\n- Configuration files for client and server will be in\n `/usr/local/etc`\n\n#### Step 2: Obtain and set up dictionaries\n\nThe dictionary or reference files the `dictd` daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster's 1913 dictionary (which is in public domain).\n\n` wget `[`ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz`](ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz)\n\nOnce you untar the archive, place the two files `web1913.dict.dz` and\n`web1913.index` in a convenient location. I placed mine at\n`/usr/share/dictionaries`. Make sure these are readable!\n\n` chmod a+r web1913.dict.dz web1913.index`\n\nYou can obtain other dictionaries by perusing [the FTP site you got the\nWebster's dictionary from](ftp://ftp.dict.org/dict/pre/)\n\n**Note**: `/usr/share/dict` is *not* an appropriate location!\n`linux.words` is the file used by the `passwd` command, for instance, to\ndetermine weak passwords.\n\n#### Step 3: Configure dict\n\nYou now need to create two configuration files for the dict server and\nclient: `dictd.conf` and `dict.conf` respectively. These need to go in\n`/usr/local/etc`\n\n##### Configure dictd server\n\n`dictd.conf` will contain references to the database(s) from Step 2.\n\n`  database web1913 { data \"/usr/share/dictionary/web1913.dict.dz\" ` \n`                     index \"/usr/share/dictionary/web1913.index\" }`\n\nIf you installed another reference database from [the FTP\nsite](ftp://ftp.dict.org/dict/pre/) in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:\n\n`  database elements { data \"/usr/share/dictionary/elements.dict.dz\" ` \n`                     index \"/usr/share/dictionary/elements.index\" }`\n\nAfter this stage, start the dictd server\n\n`  /usr/local/sbin/dictd start`\n\nTest your installation with something\n\n` dictd --test perspicacious`\n\n##### Configure dict client\n\n`dict.conf` can contain a single server or a list of servers which have\nthe `dictd` daemon running. In this example, we'll use our own machine\n\n` server localhost`\n\nAnd that's it! Test this with\n\n` dict surreptitious`\n\n### Other notes\n\nYou might need an init script if `dict word` does not work.\n\n DICTD=/usr/local/bin/dictd\n\n # DICTD_OPTIONS=\"-put -command_line -options -for -dictd -here\"\n DICTD_OPTIONS=\"\"\n DICTD_PID_FILE=/etc/dictd.pid\n\n case \"$1\" in\n 'start')\n if [ -x $DICTD ]; then\n echo \"dictd starting.\"\n $DICTD $DICTD_OPTIONS\n else\n echo \"dictd.init: cannot find $DICTD or it's not executable\"\n fi \n ;; \n 'stop')\n if [ ! -f $DICTD_PID_FILE ]; then\n exit 0\n fi \n dictdpid=`cat $DICTD_PID_FILE`\n if [ \"$dictdpid\" -gt 0 ]; then\n echo \"Stopping the dictd server.\"\n kill -15 $dictdpid 2>&1 > /dev/null\n fi \n rm -f $DICTD_PID_FILE\n ;; \n *)\n echo \"Usage: dictd.init { start | stop }\"\n ;;\n esac\n exit 0\n\n### To Do\n\n- Add information on doing this securely (i.e. dictd should use only\n one port in iptables)\n\n\n\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-20T19:56:43Z", "id": "108a1c686c01caaa2ba6ddb435008cab1fd644c2", "shortId": "108a1c68", "subject": "Dictd and Dictionaries on Linux : First Draft", "content": "When connected to the internet, there exist many ways to look up a word.\n[Answers.com](http://answers.com),\n[Dictionary.com](http://dictionary.com) are all valid resources if using\na browser. Command line checks (I find) are far faster and there exist\nways to cache a dictionary for really quick lookups if you're on OS X or\nLinux (Cygwin on Windows). And it does not stop with dictionaries: you\ncan add periodic table listings, Wikipedia, the CIA world factbook, the\ncomputer jargon dictionary, WebMD, and many more resources.\n\n### Command-line tricks\n\nOn the command line, it is possible to use `curl` to get a dictionary\nreference. We can first list all the dictionaries available at\n[dict.org](http://dict.org) like so:\n\n` curl `[`dict://dict.org/show:db`](dict://dict.org/show:db)\n\nThis lists all available dictionaries and their shortnames:\n\n` gcide \"The Collaborative International Dictionary of English v.0.48\"` \n` wn \"WordNet (r) 2.   ` \n` moby-thes \"Moby Thesaurus II by Grady Ward, 1.0\"` \n` elements \"Elements database 20001107\"` \n` vera \"Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)\"` \n` jargon \"Jargon File (4.3.1, 29 Jun 2001)\"` \n` foldoc \"The Free On-line Dictionary of Computing (27 SEP 03)\"` \n` easton \"Easton's 1897 Bible Dictionary\"` \n` hitchcock \"Hitchcock's Bible Names Dictionary (late 1800's)\"` \n` bouvier \"Bouvier's Law Dictionary, Revised 6th Ed (1856)\"` \n` devils \"THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)\"` \n` world02 \"CIA World Factbook 2002\"` \n` .` \n` .` \n` .` \n` eng-fra \"English-French Freedict Dictionary\"`\n\nTo look up a word or phrase from a certain dictionary, issue:\n\n`curl `[`dict://dict.org/d:word_goes_here:dictionary_short_name_here`](dict://dict.org/d:word_goes_here:dictionary_short_name_here)\n\nFor instance, I'll attempt to look up India in the CIA World FactBook\n(2002 edition):\n\n`curl `[`dict://dict.org/d:India:world02`](dict://dict.org/d:India:world02)` > India.Reference.txt`\n\nAnd obtain this (partial dump):\n\n` 20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686 `` <62887065.988.1256582810@miranda.org>` \n` 250 ok` \n` 150 1 definitions retrieved` \n` 151 \"India\" world02 \"CIA World Factbook 2002\"` \n` India` \n` ` \n` Introduction India` \n` ------------------` \n` Background: The Indus Valley civilization, one ` \n` of the oldest in the world, goes` \n` back at least 5,000 years. Aryan` \n` tribes from the northwest invaded` \n` about 1500 B.C.; their merger with` \n` the earlier inhabitants created the ` \n` classical Indian culture. Arab` \n` incursions starting in the 8th` \n` century and Turkish in 12th were` \n` followed by European traders` \n` beginning in the late 15th century.` \n` By the 19th century, Britain had ` \n` assumed political control of` \n` virtually all Indian lands.`\n\n### Offline Dictionaries\n\nThe example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there's a tool for precisely this\npurpose on Linux called [**dict**](http://www.dict.org/bin/Dict) and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.\n\nThe utility is split into two tools: `dictd` (the server daemon) and\n`dict` (the client application.)\n\nThe `dict` client, by itself, can search the resources at dict.org if\nyou don't want to install the server. What follows is a guide to\ninstalling the `dictd` daemon and configuring the client app to look at\n'itself' (i.e. localhost)\n\n#### Step 1: Obtain and install dict\n\n`  wget `[`ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz`](ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz)\n\nWhere 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the [typical installation\ninstructions](ftp://ftp.dict.org/dict/INSTALL) to compile this from\nsource.\n\n**Note**: You might get compiler warnings when running `make` against\nlower version numbers [since this is a\nbug](http://bugs.gentoo.org/81211).\n\nA few things:\n\n- If you did not use `--prefix` when running `configure`, the path to\n `dictd` (server) should be `/usr/local/sbin`\n- Configuration files for client and server will be in\n `/usr/local/etc`\n\n#### Step 2: Obtain and set up dictionaries\n\nThe dictionary or reference files the `dictd` daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster's 1913 dictionary (which is in public domain).\n\n` wget `[`ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz`](ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz)\n\nOnce you untar the archive, place the two files `web1913.dict.dz` and\n`web1913.index` in a convenient location. I placed mine at\n`/usr/share/dictionaries`. Make sure these are readable!\n\n` chmod a+r web1913.dict.dz web1913.index`\n\nYou can obtain other dictionaries by perusing [the FTP site you got the\nWebster's dictionary from](ftp://ftp.dict.org/dict/pre/)\n\n**Note**: `/usr/share/dict` is *not* an appropriate location!\n`linux.words` is the file used by the `passwd` command, for instance, to\ndetermine weak passwords.\n\n#### Step 3: Configure dict\n\nYou now need to create two configuration files for the dict server and\nclient: `dictd.conf` and `dict.conf` respectively. These need to go in\n`/usr/local/etc`\n\n##### Configure dictd server\n\n`dictd.conf` will contain references to the database(s) from Step 2.\n\n`  database web1913 { data \"/usr/share/dictionary/web1913.dict.dz\" ` \n`                     index \"/usr/share/dictionary/web1913.index\" }`\n\nIf you installed another reference database from [the FTP\nsite](ftp://ftp.dict.org/dict/pre/) in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:\n\n`  database elements { data \"/usr/share/dictionary/elements.dict.dz\" ` \n`                     index \"/usr/share/dictionary/elements.index\" }`\n\nAfter this stage, start the dictd server\n\n`  /usr/local/sbin/dictd start`\n\nTest your installation with something\n\n` dictd --test perspicacious`\n\n##### Configure dict client\n\n`dict.conf` can contain a single server or a list of servers which have\nthe `dictd` daemon running. In this example, we'll use our own machine\n\n` server localhost`\n\nAnd that's it! Test this with\n\n` dict surreptitious`\n\n### Other notes\n\nYou might need an init script if `dict word` does not work.\n\n DICTD=/usr/local/bin/dictd\n\n # DICTD_OPTIONS=\"-put -command_line -options -for -dictd -here\"\n DICTD_OPTIONS=\"\"\n DICTD_PID_FILE=/etc/dictd.pid\n\n case \"$1\" in\n 'start')\n if [ -x $DICTD ]; then\n echo \"dictd starting.\"\n $DICTD $DICTD_OPTIONS\n else\n echo \"dictd.init: cannot find $DICTD or it's not executable\"\n fi \n ;; \n 'stop')\n if [ ! -f $DICTD_PID_FILE ]; then\n exit 0\n fi \n dictdpid=`cat $DICTD_PID_FILE`\n if [ \"$dictdpid\" -gt 0 ]; then\n echo \"Stopping the dictd server.\"\n kill -15 $dictdpid 2>&1 > /dev/null\n fi \n rm -f $DICTD_PID_FILE\n ;; \n *)\n echo \"Usage: dictd.init { start | stop }\"\n ;;\n esac\n exit 0\n\n### To Do\n\n- Add information on doing this securely (i.e. dictd should use only\n one port in iptables)\n\n[Category:Nikhil's Notes](Category:Nikhil's_Notes \"wikilink\")\n[Category:From a past sysadmin\nlife](Category:From_a_past_sysadmin_life \"wikilink\")\n" } ], "sizeInBytes": 6818, "source": "[TOC]\n\nOn the command line, it is possible to use `curl` to get a dictionary\nreference. We can first list all the dictionaries available at\n[dict.org](http://dict.org) like so:\n\n curl dict://dict.org/show:db\n\nThis lists all available dictionaries and their shortnames:\n\n gcide \"The Collaborative International Dictionary of English v.0.48\" \n wn \"WordNet (r) 2.    \n moby-thes \"Moby Thesaurus II by Grady Ward, 1.0\" \n elements \"Elements database 20001107\" \n vera \"Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)\" \n jargon \"Jargon File (4.3.1, 29 Jun 2001)\" \n foldoc \"The Free On-line Dictionary of Computing (27 SEP 03)\" \n easton \"Easton's 1897 Bible Dictionary\" \n hitchcock \"Hitchcock's Bible Names Dictionary (late 1800's)\" \n bouvier \"Bouvier's Law Dictionary, Revised 6th Ed (1856)\" \n devils \"THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)\" \n world02 \"CIA World Factbook 2002\" \n . \n . \n . \n eng-fra \"English-French Freedict Dictionary\"\n\nTo look up a word or phrase from a certain dictionary, issue:\n\n curl dict://dict.org/d:word_goes_here:dictionary_short_name_here\n\nFor instance, I'll attempt to look up India in the CIA World FactBook\n(2002 edition):\n\n curl dict://dict.org/d:India:world02 > India.Reference.txt\n\nAnd obtain this (partial dump):\n\n 20 miranda.org dictd 1.9.15/rf on Linux 2.6.26-2-686  <62887065.988.1256582810@miranda.org> \n 250 ok \n 150 1 definitions retrieved \n 151 \"India\" world02 \"CIA World Factbook 2002\" \n India \n   \n Introduction India \n ------------------ \n Background: The Indus Valley civilization, one  \n of the oldest in the world, goes \n back at least 5,000 years. Aryan \n tribes from the northwest invaded \n about 1500 B.C.; their merger with \n the earlier inhabitants created the  \n classical Indian culture. Arab \n incursions starting in the 8th \n century and Turkish in 12th were \n followed by European traders \n beginning in the late 15th century. \n By the 19th century, Britain had  \n assumed political control of \n virtually all Indian lands.\n\nOffline Dictionaries\n--------------------\n\nThe example above uses online resources. You might, however, need to use\nthese offline. Like everything else, there's a tool for precisely this\npurpose on Linux called [**dict**](http://www.dict.org/bin/Dict) and is\nquite flexible in terms of its features. Think client-server\narchitecture, multiple dictionary references, configurable hosts on the\nclient side, etc.\n\nThe utility is split into two tools: `dictd` (the server daemon) and\n`dict` (the client application.)\n\nThe `dict` client, by itself, can search the resources at dict.org if\nyou don't want to install the server. What follows is a guide to\ninstalling the `dictd` daemon and configuring the client app to look at\n'itself' (i.e. localhost)\n\n#### Step 1: Obtain and install dict\n\n wget ftp://ftp.dict.org/dict/dictd-1.9.15.tar.gz\n\nWhere 1.9.15 is the latest version at the time of this writing. Untar it\nand follow the [typical installation\ninstructions](ftp://ftp.dict.org/dict/INSTALL) to compile this from\nsource.\n\n**Note**: You might get compiler warnings when running `make` against\nlower version numbers [since this is a\nbug](http://bugs.gentoo.org/81211).\n\nA few things:\n\n* If you did not use `--prefix` when running `configure`, the path to\n `dictd` (server) should be `/usr/local/sbin`\n* Configuration files for client and server will be in\n `/usr/local/etc`\n\n#### Step 2: Obtain and set up dictionaries\n\nThe dictionary or reference files the `dictd` daemon requires have two\nparts: the database and the index files. In this step, we will get the\nWebster's 1913 dictionary (which is in public domain).\n\n wget ftp://ftp.dict.org/dict/pre/dict-web1913-1.4-pre.tar.gz\n\nOnce you untar the archive, place the two files `web1913.dict.dz` and\n`web1913.index` in a convenient location. I placed mine at\n`/usr/share/dictionaries`. Make sure these are readable!\n\n chmod a+r web1913.dict.dz web1913.index\n\nYou can obtain other dictionaries by perusing [the FTP site you got the\nWebster's dictionary from](ftp://ftp.dict.org/dict/pre/)\n\n**Note**: `/usr/share/dict` is *not* an appropriate location!\n`linux.words` is the file used by the `passwd` command, for instance, to\ndetermine weak passwords.\n\n#### Step 3: Configure dict\n\nYou now need to create two configuration files for the dict server and\nclient: `dictd.conf` and `dict.conf` respectively. These need to go in\n`/usr/local/etc`\n\nConfigure dictd server\n----------------------\n\n`dictd.conf` will contain references to the database(s) from Step 2.\n\n database web1913 { data \"/usr/share/dictionary/web1913.dict.dz\" \n                    index \"/usr/share/dictionary/web1913.index\" }\n\nIf you installed another reference database from [the FTP\nsite](ftp://ftp.dict.org/dict/pre/) in Step 2, append it to this file\nusing similar syntax. For instance, if I downloaded a list of chemical\nelements, I would add this:\n\n database elements { data \"/usr/share/dictionary/elements.dict.dz\"  \n                    index \"/usr/share/dictionary/elements.index\" }\n\nAfter this stage, start the dictd server\n\n`  /usr/local/sbin/dictd start`\n\nTest your installation with something\n\n` dictd --test perspicacious`\n\nConfigure dict client\n---------------------\n\n`dict.conf` can contain a single server or a list of servers which have\nthe `dictd` daemon running. In this example, we'll use our own machine\n\n` server localhost`\n\nAnd that's it! Test this with\n\n` dict surreptitious`\n\nOther notes\n-----------\n\nYou might need an init script if `dict word` does not work.\n\n```bash\nDICTD=/usr/local/bin/dictd\n\n# DICTD_OPTIONS=\"-put -command_line -options -for -dictd -here\"\nDICTD_OPTIONS=\"\"\nDICTD_PID_FILE=/etc/dictd.pid\n\ncase \"$1\" in\n 'start')\n if [ -x $DICTD ]; then\n echo \"dictd starting.\"\n $DICTD $DICTD_OPTIONS\n else\n echo \"dictd.init: cannot find $DICTD or it's not executable\"\n fi \n ;; \n 'stop')\n if [ ! -f $DICTD_PID_FILE ]; then\n exit 0\n fi \n dictdpid=`cat $DICTD_PID_FILE`\n if [ \"$dictdpid\" -gt 0 ]; then\n echo \"Stopping the dictd server.\"\n kill -15 $dictdpid 2>&1 > /dev/null\n fi \n rm -f $DICTD_PID_FILE\n ;; \n *)\n echo \"Usage: dictd.init { start | stop }\"\n ;;\nesac\nexit 0\n```\n\n### To Do\n\n* Add information on doing this securely (i.e. dictd should use only\n one port in iptables)\n", "title": "Dictd and Dictionaries on Linux", "untracked": false, "uri": "/Dictd_and_Dictionaries_on_Linux" }