Published on April 26th, 2020 📆 | 6327 Views ⚑
0WSLFetch creates colorful Windows 10 WSL Linux information
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).
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.
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:
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.
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.
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.
These variables are then outputted in the following section of the script:
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.
Gloss