3 fun Linux tools to run on Windows 10 with WSL

0


[ad_1]

The multi-tab Windows terminal with a close-up of the Ubuntu command line
Microsoft

We have shown you how to install Linux terminal in Windows 10 with Windows Subsystem for Linux. But now that you have this command line interface (CLI), what are you going to do with it? Here are some fun ideas beyond the practice.

There are a number of fun things you can do with a Linux-based command line for those who like a bit of geekery. Here are three starter projects to make the command line part of your daily routine. We have ranked these projects in terms of difficulty from easiest to most difficult, but all of these projects are still fairly easy for beginners. It’s also a great way to see what the command line can do. (And yes, it also works in WSL on Windows 11!)

This tutorial assumes you are using Ubuntu as your Linux distribution in WSL. If you are using something else, you may need to adapt these commands to your needs. Or, you can install Ubuntu as a second Linux terminal and follow along.

Before you start

One of the most important things to do while using the terminal is to keep your installed applications and utilities up to date. This requires two simple commands. The first is :

sudo apt update

Let’s break this down. Using sudo Temporarily elevates your user account to administrator privileges for this single command. Without this elevation, the command would fail. Use sudo, the terminal will ask you to enter the password you created when configuring WSL.

The next part, apt (Advanced Package Tool) is the package manager that Ubuntu uses to install programs and utilities. A package is the set of files that come together to function as a Linux program or utility. APT is smart enough to install not only the program you want, but all the dependencies it needs as well. An addiction is another program that the desired program needs to run.

Finally we have update, which is an option for APT that tells it to update the package lists from the repositories that your system uses. This is the first step in updating new versions of the programs installed in the system. Without updating the list, your system would not have enough information to complete the next step.

Our second order is:

sudo apt upgrade -y

We have already covered sudo and apt, but the new bits tell the system to upgrade our packages using the information from the list we downloaded in the previous step. The -y is called a “flag” and in this case it means “yes”. This is an optional command that allows us to skip the boring part where the system tells us how much storage the new updates are going to take up and then asks us if we want to continue.

Now that our system is up to date, we are ready to play around with some command line tools.

Get the weather

A terminal window with a weather report with ASCII art
Wttr.in provides the weather forecast to your terminal.

The easiest thing to do is to get a graphical overview of the current weather with a three day forecast using a website called wttr.in. This website reads your IP address to get your approximate location and then returns the weather to you in a terminal friendly format.

If you want to get a preview of what it will look like, you can also visit the website in a regular browser.

To get the weather forecast you need the terminal program curl, which should be installed by default on your system. If not, run sudo apt install curl to get it.

Now let’s see the weather forecast in our terminal with curl wttr.in. Within seconds you should have a weather forecast for your location similar to what you see in the photo above.

Another trick is to configure your system so that every time you open the terminal it displays the latest weather forecast. You can do this by adding the command curl wttr.in at the top of your .bashrc to file.

To understand how to edit your .bashrc file, see our previous tutorial on how to customize (and colorize) your Bash prompt.

Get MLB scores in the terminal

A terminal window displaying a baseball box score table
You can use MLB-StatsAPI to get baseball game updates in the terminal.

I have my terminal open all the time, and sometimes I don’t want to bother with Google for details on the Yankees’ latest game. Instead, I turn to a reliable Python script to get all the information I need.

If you’ve installed the latest version of Ubuntu for WSL, you already have Python 3, which is what we need for that. You can check this by typing python3 --version, which will tell you what version of Python 3 you have in your system.

Now let’s get serious. The first thing you will need is a set of helper scripts that will retrieve all the baseball data we want. It’s called statsapi, a community-based Python background app that we’ll install using PIP3. Like APT, PIP3 is a package manager, but only for programs written in Python.

First we need to install it with sudo apt install python3-pip -y. Once done, run the following command:

pip3 install MLB-StatsAPI

Now we can grab our baseball script which is based on the statsapi. The script is taken from my own GitHub repository (a repository is just a place to store code) where I have a bunch of scripts that can get information about the current baseball season.

First, let’s create a new directory (or folder) called “bin” with mkdir bin. The mkdir The command literally means “create a directory”. Then navigate to this directory with cd bin (“cd” means change directory). “Bin” is a common name for folders that contain scripts and executables (binaries) in a Linux environment, but you can name the directory any way you like.

Now we will download the script with “wget”, a command line download tool.

The command is:

https://raw.githubusercontent.com/ianpaul/Baseball_Scores/master/ballgame.py

This downloads a script called ballgame.py from the repository. The “py” file extension indicates that this is a Python script.

Now all we have to do is run our Python script using the python command:

python3 ~/bin/ballgame.py

This tells the terminal to use Python 3 to interpret the script. The ~/ means look in the home folder, then look at the bin folder in home and open the ballgame.py script.

Once you’ve done that, the script will ask you for the name of the team you’re interested in, then ask if you want to see a box score or a row score. Once the selection is made a few seconds later, you will have your game information in a terminal friendly format.

Keep in mind that this script is configured to give you the results of the last game completed. This will not give you an update for a current game.

Twitter command line

A terminal window with a stream of tweets using multiple colors of text.
Rainbow Stream is a Python-based terminal app that sends tweets at the command line.

There are a number of Twitter clients that can send your Twitter feed to the command line. The advantage of this approach is that it reduces Twitter to its purest form and makes the experience a bit calmer.

A really good Twitter CLI client is Rainbow Stream, which is based on Python and requires some of the tools we have already used in the previous steps. First of all, we need to make sure that we have all the dependencies required by Rainbow Stream. Here is the command :

sudo apt install python3-dev libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

We are not going to explain what all of these tools are. If you want to know, you can search them on Google. Each utility is separated by a space after “install” in the above command.

Now let’s install Rainbow Stream. We use the Quick Method, but if you want to use the Recommended Method, check out the Documentation of the rainbow flow.

sudo pip3 install rainbowstream

It will take a few minutes while Rainbow Stream installs.

Now make sure you are signed in to Twitter in your web browser. Then, to activate the program, type rainbowstream in the command line.

Next, Rainbow Stream will want to open a web browser tab so that you can allow the app to access your Twitter account. In some cases, this should happen automatically. If not, simply copy and paste the following URL into your web browser. The URL usually looks like this: https://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXXXXXXXX

Highlight this URL, right click to copy it, then paste it into your web browser. Twitter will ask you to authorize Rainbow Stream to give the app access to your account, then Twitter will provide you with a seven-digit PIN code. Type that PIN code into the terminal where Rainbow Stream is waiting for the code, and that’s it. Your tweets will now reach the command line after a few minutes – the first execution usually takes a while before the tweets start pouring in.

Rainbow Stream is fairly easy to use, but it does require a few commands. Typing “t here is my tweet” and pressing Enter on your keyboard will post a tweet.

Each tweet in your feed has an ID number such as “id: 8”. Typing rt 8 will retweet this tweet. Typing quote 8 allows you to tweet that same tweet and add your own comment. There are a bunch of other commands you can read in the Rainbow Stream documentation.

As with many other command line programs, you can also type h anytime for help in the app.

If you find that Unicode characters are not displayed correctly, an easy solution is to install Windows Terminal from the Windows Store.

RELATED: The new Windows terminal is ready; Here’s why it’s amazing

Using the command line takes a bit more work to get started than installing a regular program, but it can also be a very powerful, useful, and fun tool to have at your disposal.


[ad_2]

Share.

Leave A Reply