We’ve shown you how to install a Linux terminal in Windows 10 with the Windows Subsystem for Linux. But now that you’ve got this command-line interface (CLI) what are you going to do with it? Here are some fun ideas beyond the practical.
There are a number of fun things you can do with a Linux-based command line for those who love a little geekery. Here are three starter projects to incorporate the command line into your daily routine. We’ve ranked these projects in terms of difficulty from the easiest to the hardest, but all of these projects are still easy enough for beginners. They’re also an excellent way to see what the command line can do. (And yes, this works in WSL on Windows 11, too!)
This tutorial assumes you’re using Ubuntu as your Linux distribution in WSL. If you’re using something else you may have to adapt these commands to suit your needs. Or, you can install Ubuntu as a second Linux terminal and follow along.
One of the most important things to do when using the terminal is to keep your installed apps 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. To use
sudo, the terminal will ask you to enter the password that you first created when you set up WSL.
The next part,
apt (Advanced Package Tool,) is the package manager Ubuntu uses to install programs and utilities. A package is all the files that come together to work as a Linux program or utility. APT is smart enough to not only install the program you want, but any dependencies it requires. A dependency is another program that your desired program needs to work.
Finally, we have
update, which is an option for APT that tells it to update the lists of packages from the repositories your system uses. This is the first step in updating new versions of programs installed in the system. Without updating the list, your system wouldn’t have enough information to carry out the next step.
Our second command is:
sudo apt upgrade -y
We’ve already covered
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 stands for “yes.” This is an optional command that lets us skip the annoying part where the system tells us how much storage space the new updates are going to take, and then asks if we want to continue.
Now that our system is up to date, we’re ready to play around with some tools on the command line.
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 delivers the weather back to you in a terminal-friendly format.
If you want a preview of what this will look like you can also visit the website in a regular browser.
To get the weather, you need the terminal program
curl, which should be installed in your system by default. If it isn’t, run
sudo apt install curl to get it.
Now let’s see the weather in our terminal with
curl wttr.in. In a few seconds, you should have a weather forecast for your location similar to what you see pictured above.
Another neat trick is to set up your system so that every time you open the terminal it shows the latest weather forecast. You can do that by adding the command
curl wttr.in to the top of your
To understand how to edit your
.bashrc file, check out our previous tutorial on how to customize (and colorize) your Bash prompt.
I constantly have my terminal open, and sometimes I don’t want to bother with Google for details about the latest Yankees game. Instead, I turn to a trusty Python script to get all the information I need.
If you’ve installed the latest version of Ubuntu for WSL then you’ve already got Python 3, which is what we need for this. You can double-check this by typing in
python3 --version, which will tell you the version of Python 3 you’ve got in your system.
Now, let’s get down to business. The first thing you’ll need is a set of helper scripts that’s going to grab all the baseball data we want. It’s called statsapi, a community-based Python background application 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 that’s done carry out the following command:
pip3 install MLB-StatsAPI
Now, we can grab our baseball script that relies on the
statsapi. The script is coming 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 make a new directory ( or folder) called “bin” with
mkdir bin. The
mkdir command literally means “make directory.” Then, change to that 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 whatever you want.
Now, we’ll download the script with “wget”, a command line downloading tool.
The command is:
This downloads a script called ballgame.py from the repository. The “py” file extension denotes that this is a Python script.
Now, all we have to do is run our Python script using the python command:
This tells the terminal to use Python 3 to interpret the script. The
~/ means look in the home folder, and then look at the
bin folder in home and open the script ballgame.py.
Once you do that, the script will ask for the name of the team you’re interested in, and then ask if you want to see a box score or line score. Once you make the selection a few seconds later, you’ll get your game information in a terminal-friendly format.
Keep in mind this script is set up to give you the results of the last completed game. It won’t give you an update to an ongoing game.
There are a number of Twitter clients that can deliver your Twitter feed to the command line. The nice thing about this approach is that it reduces Twitter to its purest form, and it makes the experience a little calmer.
A really good CLI Twitter client is Rainbow Stream, which is based on Python and requires some of the tools we’ve already used in the previous steps. First, we need to make sure we have all the dependencies that Rainbow Stream requires. Here’s the command:
sudo apt install python3-dev libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
We’re not going to explain what all of these tools are. If you want to know you can search for them on Google. Each utility is separated by a space after “install” in the command above.
Now, let’s install Rainbow Stream. We’re using the quick method, but if you’d like to use the recommended way check out the Rainbow Stream documentation.
sudo pip3 install rainbowstream
This will take a few minutes as Rainbow Stream installs itself.
Now make sure you’re signed in to Twitter in your web browser. Then to activate the program, type
rainbowstream into the command line.
Next, Rainbow Stream will want to open a web browser tab so that you can authorize the app to access your Twitter account. In some cases, this should happen automatically. If it doesn’t, just copy and paste the following URL into your web browser. The URL typically looks something like this: https://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXXXXXXXX
Highlight that URL, right-click to copy, and then paste it into your web browser. Twitter will ask you to authorize Rainbow Stream to give the app access to your account, and then Twitter will provide a seven-digit PIN. Type that PIN into the terminal where Rainbow Stream is waiting for the code, and that’s it. Your tweets will now hit the command line after a few minutes—the initial run usually takes some time before the tweets start pouring in.
Rainbow Stream is pretty easy to use, but it does require a few commands. Typing “t here is my tweet” and hitting Enter on your keyboard will publish a tweet.
Each tweet in your stream has an id number such as “id:8.” Typing
rt 8 will retweet that tweet. Typing
quote 8 allows you to quote tweet that same tweet and add your own commentary. There are a bunch of other commands you can read about in the Rainbow Stream documentation.
As with many other command-line programs, you can also type
h at any time to get in-app help.
If you find that Unicode characters aren’t displaying correctly, then an easy solution is to install Windows Terminal from the Windows Store.
Using the command line does take a little more work to get going than installing a regular program, but it can also be a very powerful, useful, and fun tool to have at your disposal.