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.


Please enter your comment!
Please enter your name here




How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

5 Ways to Open a Terminal in Ubuntu

Even though Ubuntu supports many applications with amazing Graphical User Interfaces (GUI), there are always reasons why users prefer using the Terminal to perform different tasks.

How to install Wine on Fedora Workstation

Linux distributions are becoming more and more popular every day, and Fedora Workstation is not left behind. This popularity brings forth the need to run Windows applications on Linux distros like Fedora. Windows has quite some excellent Software that is not available for Linux.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

What is the difference between Linux and Unix?

When discussing Linux and Unix with average users, it's not uncommon that they will sometimes mistakenly interchange the terms Linux and Unix.  The two are not the same.  Though they share similarities in their overall structures and toolkits, they are decidedly not the same.

5 ways to check if a Port is open on a remote Linux PC

There is an ample number of ways to check for any open ports on a remote Linux PC. Knowing open ports on a Linux machine helps system administrators to connect to the remote PC for troubleshooting system and cloud server issues.

CopyQ – Advanced clipboard manager for Linux

We have all had that moment when we copied a text, but we first needed another one, and in the process, lost the first one. If you're lucky, you can get it back quickly with a bit of work.

Best Laptops for Linux and Apps Development [2020]

Apart from your programming skills, there are a few other things that can also influence the way you code, and one of them is your computer system for sure. Even though it isn't like you can't code on a regular PC or laptop, speaking from personal experience, you can make the most out of your programming skillset by going for a computer with high specs and one that's been specially designed for such tasks.