Featured

Published on April 26th, 2020 📆 | 6327 Views ⚑

0

WSLFetch creates colorful Windows 10 WSL Linux information


iSpeech.org

If you want to show off what Windows Subsystem for Linux distribution you are using in Windows 10, you can do so in style using the WSLFetch utility.

Similar to Neofetch, WSLFetch is a tool bundled with Microsoft's optional Windows Subsystem for Linux Utilities (WSLU) package that prints out colorful Linux ASCII logos along with some basic information about the distro that you are running.

While the Ubuntu WSL distro includes the 'wslfetch' command, all of the other Linux distributions offered on the Microsoft Store require you to install the WSLU package first.

Below we will provide information on how to install WSLFetch in your WSL distributions as well as enhance it to show more details about the device's hardware.

Ubuntu

In Ubuntu 20.04, the WSLU package is installed by default, so you can run the wslfetch command after installing the distribution from the Microsoft Store.

When running wslfetch, the script will display a colorful ASCII Ubuntu logo as well as basic information about the install, such as the Windows build, development branch, Linux distribution version, Linux kernel version, and how long the distro has been running (uptime).

WSLFetch output for Ubuntu 20.04
WSLFetch output for Ubuntu 20.04

It is not known if the previous Ubuntu 18.04 LTS version had this command available by default.

Debian

Debian does not have the WSLU package installed, so you need to manually install it using the following commands:

sudo apt update
sudo apt install gnupg2 apt-transport-https
sudo apt install wget
wget -O - https://access.patrickwu.space/wslu/public.asc | sudo apt-key add -
echo "deb https://access.patrickwu.space/wslu/debian buster main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install wslu

When done, you can now run the wslfetch command to print out an ASCII Debian logo along with some basic information, as shown below.

WSLFetch output for Debian 10
WSLFetch output for Debian 10

Kali Linux

To install the WSLU package on Kali Linux, you need to enter the following commands:

sudo apt update
sudo apt install gnupg2 apt-transport-https
wget -O - https://access.patrickwu.space/wslu/public.asc | sudo apt-key add -
echo "deb https://access.patrickwu.space/wslu/kali kali-rolling main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install wslu

When done, wslfetch will display the following screen:

WSLFetch output on Kali Linux
WSLFetch output on Kali Linux

OpenSuse/SUSE

Finally, like most other distributions, OpenSUSE and SUSE do not have the WSLU package installed by default.

To install WSL in OpenSUSE/SUSE, use the appropriate commands depending on what distro you are installing.

OpenSUSE install commands:

sudo zypper addrepo https://download.opensuse.org/repositories/home:/wslutilities/openSUSE_Leap_15.1/home:wslutilities.repo
sudo zypper up
sudo zypper in wslu

SUSE install commands:





SLESCUR_VERSION="$(grep VERSION= /etc/os-release | sed -e s/VERSION=//g -e s/"//g -e s/-/_/g)"
sudo zypper addrepo https://download.opensuse.org/repositories/home:/wslutilities/SLE_$SLESCUR_VERSION/home:wslutilities.repo
sudo zypper addrepo https://download.opensuse.org/repositories/graphics/SLE_12_SP3_Backports/graphics.repo
sudo zypper up
sudo zypper in wslu

When done,  wslfetch will display a screen similar to the following image.

WSLFetch output for Open Leap 15.1
WSLFetch output for Open Leap 15.1

Enhancing WSLFetch

Unlike Neofetch, WSLFetch only displays information about the Linux distribution that you are using and does not show any information about a computer's hardware.

The nice thing about WSLFetch is that it is a shell script, which means you can easily modify it to show more information about the Windows 10 device that the distribution is installed.

For example, you can see how BleepingComputer enhanced WSLFetch to also report the number of packages installed, the installed CPU, and the total memory in the system.

Enhancing WLSFetch to show hardware info
Enhancing WLSFetch to show hardware info

To improve WSLFetch so that it shows more detailed information, you can edit the /usr/bin/wslfetch script and capture the output of additional commands into variables in the script.

These variables are all located in the same location, as shown below.

Information variables
Information variables

These variables are then outputted in the following section of the script:

Outputting the variables
Outputting the variables

To add additional information for the number of packages, installed CPU, and total memory, BleepingComputer added the following variables:

Packages:

packages=$(echo "$wslsys" | grep -Po '^Packages Count: K.*')

CPU:

cpuinfo=$(cat /proc/cpuinfo | grep "model name"| uniq | awk -F':' '{print $2}' | sed -e 's/^[[:space:]]*//')

Total memory:

meminfo=$(awk '$3=="kB"{if ($2>1024^2){$2=$2/1024^2;$3="GB";} else if ($2>1024){$2=$2/1024;$3="MB";}} 1' /proc/meminfo | column -t | awk 'NR==1{print $2 $3}')

We then modified the output of the script to include these variables.

info_text=("${t}Windows 10 Linux Subsystem${reset}"
"${t}${USER}${reset}@${t}${hostname}${reset}"
"${t}BUILD:${reset}     ${build}"
"${t}BRANCH:${reset}    ${branch}"
"${t}RELEASE:${reset}   ${release}"
"${t}KERNEL:${reset}    ${kernel}"
"${t}UPTIME:${reset}    ${uptime}"
"${t}PACKAGES:${reset}  ${packages}"
"${t}CPU:${reset}       ${cpuinfo}"
"${t}MEMORY:${reset}    ${meminfo}"
"${reset}"
)

Being able to easily extend WSLFetch can make it a much more informative, fun, and useful tool to use.

Let us know what else you have added or how you improved the WSLFetch utility.

Source link

Tagged with: • • • • • •



Comments are closed.