How to search Wikipedia by command-line on Ubuntu

Wikipedia2text command-line utility lets you search the Wikipedia from the Linux Terminal. You can optionally launch the GUI browser if needed.

Querying Wikipedia by command line via Ubuntu’s Terminal is great fun. Today, I’m going to show you just that by using a free utility called wikipedia2text. This command-line utility queries the search term from the Wikipedia website and displays the result in the form of text within the Terminal.

You may want to know why one would search Wikipedia from Terminal? The reason can be as simple as you are operating a remote PC and would like to quickly search about a term in the world’s biggest database. Wikipedia2text doesn’t stop there. If needed, it can open the Wikipedia article in a GUI web browser or shows the URL of the relevant Wikipedia article.

Searching Wikipedia by command-line from Terminal

Before starting in the wikipedia2text installation, you need to make sure that you have a terminal-based web browser installed on your machine.

Step 1. In case you do not have a terminal-based web browser installed, then use the next command to install the Links web browser. Otherwise, skip this step if you have a terminal-based web browser installed.

sudo apt install links

Install The Links Terminal Web Browser
Installing the Links Terminal Web Browser

Step 2. Now let’s install the wikipedia2text package using the following command.

sudo apt-get install wikipedia2text

Install The wikipedia2text Package
Installing wikipedia2text Package

Step 3. You can start querying Wikipedia after the installation is complete. You can use the wikipedia2text to help command to know the command usage of the utility. Enter the following command:

wikipedia2text -help

The wikipedia2text Help Command
The wikipedia2text Help Command

Step 4. To show you an example of how to use query string, let’s search Wikipedia for “Ubuntu,” use the next command.

wikipedia2text ubuntu

The previous command will search for the Ubuntu article in Wikipedia and will preview the result directly in your terminal, as you can see in the below screenshot.

Search For Ubuntu Articles In Wikipedia
Search For Ubuntu Articles In Wikipedia

Step 5. To preview results in a pager mode, use the next command.

wikipedia2text -p ubuntu

As you will notice, the pager mode will preview the result page by page; to move to the next page, press the space bar. If you need to quit the preview, press the “q” letter to exit.

Result For Ubuntu Articles In Wikipedia With The Pager Option
Result For Ubuntu Articles In Wikipedia With The Pager Option

Step 6. To get results from Wikipedia in a different language, you can use the following command.

wikipedia2text -pl fr ubuntu

The above command will display the Ubuntu article from Wikipedia in the French language.

As you can see in the Ubuntu article is displayed in the French language.

Result For Ubuntu Articles In Wikipedia With The Pager Option In French Language
Result For Ubuntu Articles In Wikipedia With The Pager Option In the French Language

Step 7. In case you need to get the Wikipedia URL for a specific article, uses the following command.

wikipedia2text -u ubuntu

Get The URL Of A Wikipedia Ubuntu Article
Get The URL Of A Wikipedia Ubuntu Article

Congratulations, you have just learned how to search Wikipedia from your terminal.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,328FansLike
190FollowersFollow

LATEST ARTICLES

RECENT COMMENTS

best video players for linux
Most Linux-based systems come with a built-in video player, but let's be honest, it most definitely won't be able to satisfy all of your requirements, due to the fact that default software is mostly made for basic purposes. In this article, we will review the 5 Best Video Players for Linux and thoroughly discuss their features as well as their pros and cons.
Application Launchers for Ubuntu
Ubuntu is one of the most used Linux distributions worldwide. It is also the reason why it has the maximum number of available programs for itself. Today we are going to talk about one category of those programs, the application launchers.
best linux distros beginners
Making the shift to Linux is not as complicated as some people make it out to be. There is a variety of Linux distributions available that cater to the needs of people who are planning on making the jump to Linux from any other operating system.