How to Get Wikipedia Article Summaries in Linux Command Line
Wikipedia has now become the go-to encyclopediac ecosystem on the Internet. Edited, maintained and supported by millions all over the world, it is the most successful decentralized information creation platform. Increasing strictness over the years on citing references has ensured reduced vandalism and promotional content.
The node package
wikit offers a way to fetch and display the summary section of any Wikipedia article. It also works for Wikipedias of other languages. Let’s see how to install and use
To install wikit, you need to have
nodejs as well as
npm installed on your system. For Ubuntu and Debian, use:
sudo apt install nodejs npm
Note: For older Ubuntu versions (version 14.04 and below), you need to use
apt-get instead of
For CentOS, Fedora, and other Red Hat based distributions, refer to instructions given here.
Node package binaries are generally installed in
/home/<user>/node_modules/.bin. To add this path to your
PATH environment variable permenantly, run:
sudo vim ~/.bash_profile
In this file, add the following code:
To save the file and exit
vim editor, press
Escape to go to vim command mode, then type
:wq to save and exit the file.
The commands in Bash Profile file are run each time a terminal session is opened. Hence, either restart the terminal or open a new terminal for these changes to take place.
After installing npm, you can install wikit using:
npm install wikit
If you get warnings such as “npm doesn’t support Node.js v10.15.2” or a different version. Then, you need to update Node.js to the latest version on your system.
To upgrade Node.js to the latest stable version, run the following commands one by one:
sudo npm cache clean -f sudo npm install -g n sudo n stable
After updating Node.js, run the
wikit installation command again. It’ll install without error this time.
To verify wikit has installed on your system, run:
To get summary of a particular article, run:
# wikit <article_name> # Eg : wikit nodejs
If article name contains spaces, no need to enter it in quotes.
wikit Linux Kernel
If article name is not correctly known, or if there is disambiguation in article name, you can type part of the name, and
wikit will display list of articles similar to that name, from which user can choose.
You can move up and down to mark required entry, and then press enter to display summary of that article.
To open the Wikipedia article in default browser, run:
wikit nodejs -b
To open it in a particular browser, run:
wikit nodejs --browser Firefox
To fetch summary of an article in a language other than English, use
--lang flag. Eg. To fetch an article from the Hindi Wikipedia, use:
wikit प्रेमचंद --lang hi