I used to guide you how to install Linux Terminal on Windows 10 using WSL. But now that you can use this command line interface (CLI), what do you do with it? Here are 3 cool Linux tools that I think you’ll enjoy.
Join the channel Telegram of the AnonyViet 👉 Link 👈 |
There are some cool things you can do with the Linux-based command line. Here are three starter projects to incorporate the command line into your daily routine. I’ve ranked these projects from easiest to hardest, but all of these projects are still easy enough for newbies. This is also a great opportunity to see what the command line can do.
This tutorial assumes that you are using Ubuntu as your Linux distribution in WSL. If you are using another Distro, you may have to adapt these commands to your needs. Or, you can install Ubuntu in WSL and follow this article.
Prepare
One of the most important things to do when using Terminal is to update your installed applications and utilities. This requires two simple commands. The first command is:
sudo apt update
Use sudo to temporarily elevate your user account to administrator privileges for this command. Without this privilege, the command will fail. To use sudo, the terminal will ask you for the password you first created when setting up WSL.
The next part, apt (Advanced Package Tool,) is the package manager Ubuntu uses to install programs and utilities. Packages are all files that come together to act as a Linux program or utility. APT is smart enough to not only install the program you want, but also install any dependencies it requires. Dependencies are another program that the program you want to install needs to work.
Finally, is update, an option for APT that allows it to update the list of packages from the repositories your system is using. This is the first step in updating new versions of programs installed in the system. If these software are not updated, your system will not have enough information to take the next step.
The second command is:
sudo apt upgrade -y
-Y is called “flag” and in this case it stands for “yes”. This is an optional command that allows us to skip the annoying system questions.
Now that our system is up to date, we are ready to use some of the tools on the command line.
3 Cool Linux Tools to Run on WSL
Get weather information
The easiest tool to experiment with is to get a graphical overview of the current weather with a three-day forecast using a website called wttr.in. This site reads your IP address to get your approximate location and then provides the weather information back to you in a more user-friendly format in the terminal.
If you want to preview this look, you can also access the website using a regular browser.
For weather you need curl, this program will be installed in your system by default. If not, run the command sudo apt install curl
to install curl.
In a few seconds you will have a weather forecast for your location similar to what you see in the image above.
Another trick is to set up your system so that every time you open Terminal, it shows the latest weather forecast. You can do that by adding command write command curl wttr.in
at the beginning of the .bashrc file.
Get MLB Points in Terminal
I constantly open Terminal and sometimes don’t want to go to Google for the latest Yankees match information. Instead, I write a reliable Python script to get all the information I need.
If you have installed the latest version of Ubuntu for WSL then you already have Python 3, this is what we need for this. You can double-check this by typing python3 --version
this command will tell you the version of Python 3 you have in your system.
Now, let’s get to work. The first thing you need is a set of helper scripts that will get all the baseball data we want. It’s called statsapi, a community-based Python application that installs using PIP3. Like APT, PIP3 is a package manager, but only for programs written in Python.
First we need to install it using the command sudo apt install python3-pip -y
. Once done, execute the following command:
pip3 install MLB-StatsAPI
Now, we can get baseball scores based on statsapi. The script is in the GitHub repository (the repository is just a place to store the code), where I have a bunch of scripts that can get information about the current baseball season.
First, create a new folder named “bin” with the command mkdir bin
. The mkdir command literally means “make directory”. Then change that directory with cd bin
(“cd” means change directory). “Bin” is the common name for directories containing scripts and executables (binaries) in a Linux environment, but you can name the folder however you like.
Now, we will download the script with “wget”:
wget https://raw.githubusercontent.com/ianpaul/Baseball_Scores/master/ballgame.py
This downloads a script called ballgame.py from the repository. The file extension “py” denotes that this is a Python script.
Now, all we have to do is run our Python script with the python command:
python3 ~/bin/ballgame.py
This command tells Terminal to use Python 3 to run the script. ~/ Means go to home directory then go to bin directory in home and open ballgame.py script.
After you run the above command, the script will ask for the name of the team you’re interested in, then ask if you want to see box points or line points. Once selected, you will receive match information in a terminal-friendly format.
Remember that this script is set up to give you the results of the completed match. It will not provide scores of ongoing matches.
Twitter on Terminal
There are several applications that can feed your Twitter feed to the command line. What’s cool about this approach is that it reduces Twitter to its purest form, and it makes the experience a bit simpler.
A really good Twitter CLI application is Rainbow Stream, which is based on Python and requires some of the tools we used in the previous steps. First, we need to make sure we have all the dependencies that Rainbow Stream requires:
sudo apt install python3-dev libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
I won’t explain what all these tools are. If you want to know, you can search them on Google. Each widget is separated by a space.
Now let’s install Rainbow Stream:
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 terminal.
Next, Rainbow Stream will open a web browser tab so you can allow the app to access your Twitter account. In some cases, this process will happen automatically. Otherwise, just 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 that URL, right-click to copy, and then paste it in your web browser. Twitter will ask you to allow Rainbow Stream to grant the app access to your account, and then Twitter will provide a seven-digit PIN. Enter that PIN in the terminal where Rainbow Stream is waiting for the code and that’s it. Your tweets will now appear on the command line in a few minutes.
Rainbow Stream is pretty easy to use, but it requires a few commands. Typing “t here is my tweet” and pressing Enter on your keyboard will post a tweet.
Each of your tweets will have an id number, such as “id:8”. Import rt 8
will repost that tweet. Import quote 8
allows you to quote that tweet and another tweet and add your own comments. There are many other commands that you can read about in the Rainbow Stream documentation.
As with many other command line programs, you can also type h
anytime to get help within the app.
If you find that Unicode characters do not display correctly, the easiest solution is to install Windows Terminal from the Windows Store.
Using the command line takes a little more work than installing a regular program, but it can also be a very powerful, useful, and fun tool to use.