0% found this document useful (0 votes)
98 views

Installing WSL

How to enable Windows Subsystem for Linux
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
98 views

Installing WSL

How to enable Windows Subsystem for Linux
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 24
CHAPTER 2 Downloading, Installation, and Setup ‘The Windows Subsystem for Linux is a compatibility feature that acts as a translation. layer, but is a Windows feature that has to be enabled before use. Then we need to install a Linux distribution from the Microsoft Store and finally set it up before first use. Let’s get started with each of these steps one by one. Enabling the WSL Feature ‘The Windows Subsystem for Linux needs to be enabled at the host operating system level, and there are two ways to achieve this: first using the graphical user interface (GUD) and second using PowerShell. Unless you enable the Windows Subsystem for Linux feature, you can't run WSL on your system and you will receive the following error as demonstrated in Figure 2-1. Thi s image was captured on my ystem by installing Linux distribution without enabling the WSL feature, hence the error. @ vewns linstalting, this way take a few winutes, ! indows Subsystem for Linux optional component is rot enabled. |Please enable it and try again ot enabled Figure 2-1. WSL feature Let's start with the first approach. 19 © Prateek Singh 2020 Singh, Learn Windows Subsystem for Linus, btps://do.og/101007/970-1-4842-0038-8. 2 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP GUI Approach ‘To enable WSL from GUI, follow these steps: 1. Press Windows + R key to launch Run dialog. 2. Now type appwiz.cpl and hit the Enter button or click OK, like in Figure 2-2 3 Run x Internet resource, and Windows wll pent or you. ee Oe EE Figure 2-2. Launch “Program and Features” 3. This will pop up the “Program and Features" window, where you have to select “Turn Windows features on or off” from the top-left corner as highlighted in Figure 2-3. 20 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP 14 (E> contol Pane > Programs > Programs and Fates ‘arc tee Home Uninstall or change a program Te nina a program ste it om tes an onpaize ~ 8 Dropbox Sitveson2210 © coos!eOvome ere prose wees Semuare Sricorot Om Ore SB crosot Teams Bcrosot Visa Co+ 2013 Resiuibuabie 54) = Birra Visa Cs 2013 Resiinatable 06) Figure 2-3. Select “Turn Windows features on or off” 4, Anew “Windows Features’ window will pop up on your screen. Please scroll down and left-click to select the check box next to “Windows Subsystem for Linux” (Figure 2-4). i Windows Features Turn Windows features on or off e ‘Totuma feature on select is check bo. To tum a feature off, clear is check box. fled box means that only par ofthe feature turned on ‘MB Direct * Telnet Client TFIPChent Vial Machine Platform Windows Defender Application Guard iadons Hyperssor Pato Windows identity Foundation 35 Windows PowerShell 20 Windows Process Activation Service sbagosoooosog Work Folders Cent ¥ | Om | Figure 2-4. Click the “Windows Subsystem for Linux” feature check box a CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP 5. This will enable the Windows feature, butit will be still required to reboot your system to see the configuration and changes to take effect. Once the system is rebooted, you can now run WSL. on without observing any error like we saw in Figure 2-1. Now let's look at the second approach using PowerShell. PowerShell Approach Enabling the Windows Subsystem for Linux using PowerShell is a simple process: 1. Running the following cmdlet is probably the easiest way: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft -Windows-Subsystem-Linux 2. Once you run that, itwill prompt to restart your system as shown, in Figure 2-5. Press “Y" and hit Enter to enable the Windows feature. \> cnable-tiindowsoptionalFeature -Online -FeatursName HicrosoFt-hindows-Subaysten-Linux Yyou want to restart the conputer to complete this operation non? [fr) Ves" [wu] No [2] Help (default ts"): Figure 2-5. Press “Y” to confirm enabling the feature Download and Install Linux Distributions (Distros) After enabling the Windows feature to support the Windows Subsystem for Linux, you have to then install a Linux distribution package from one of the Microsoft partners like Ubuntu, Debian, Kali Linux, and so on to run an instance of WSL. There are multiple ways to download distribution packages (distros), some of which are listed as follows, with the exact steps you need to perform. 22 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Downloading from Microsoft Store Linux distributions can be directly downloaded from the Microsoft Store with help of the following instructions: 1. Glick the Start menu, and search for “Microsoft Store” Then clickit to launch the Microsoft Store. 2, Inthe top-right corner, there is a search box (step 1); type “Linux” and hit Enter. You will see some Linux distribution packages in the search results. 3, Just for the sake of an example, we will download Ubuntu 18.04 LT (distro) from the Microsoft Store, by clicking it (step 2) as demonstrated in Figure 2-6. me = ER de hel ees a ee eeeke oe fe — ara ea | APPS (82) sow Figure 2-6. Search the distribution and click it 4, This will open the distribution page, where you will find an “Install” button in the top-right comer as shown in Figure 2-7, and once you click this button, it will begin installing the distribution, on your system, which will be available as an application on Windows. 23, CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP © Home Apps ames eNces Modes TY Kage terion Psenm Wan B e---- — | Ubuntu 18.04 LTS. Canonical Group Lines * Osler tole > Servers eee 19 2 sme PNT tin 20400 wedors ators ones tut Tanda command ‘ine ues nung bash sh apt ond may more — io Figure 2-7. Click the “Install” button Downloading a Distro Manually Microsoft has created direct inks to download a lot of popular Linux distributions through https: //aka.ms/ styled short URLs, as listed in Table 2-1. That means you can go to one of these URLs and download a Linux distribution, and this approach can. be very useful if Microsoft Store has been disabled/blocked on your system through a Group Policy. 24 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Table 2-1. Linux distributions and direct download URLs Distribution Name Download URL Ubuntu 18.04 https: //aka.ms/wsl-ubuntu-1804 Ubuntu 18.04 ARM https: //aka.ms/ws1-ubuntu-1804-arm Ubuntu 16.04 https: //aka.ms/wsl-ubuntu-1604 Debian GNU/Linux https: //aka.ms/ws1-debian-gnul inux kali Linux https: //aka.ms/ws1-kali-linux OpenSUSE Leap 42 https: //aka.ms/ws1-opensuse-42 SUSE Linux Enterprise 12 https: //aka.ms/ws1-sles-12 Fedora Remix for WSL https: //github.con/bhitewaterFoundry/ WSLFedoraRemix/releases/ Once the download is complete, please double-click the application package (apps) file to install the Linux distribution as demonstrated in Figure 2-8, Install Kali Linux? Ciivsted Mrot Stor Ar Pobleer Kl Un Version 1.140 Copa: BE Larch when ready gala) \ = Figure 2-8. Installing the distro application package (*.appx) after download CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Downloading Using PowerShell WSL distribution packages can be easily downloaded with PowerShell, using the Invoke-WebRequest cmdlet and passing the direct download URL as an argument to the “-URI" parameter. PowerShell code in Listing 2-1 demonstrates how to download the Ubuntu 18.04 application package. Similarly, other URLs mentioned in the previous sections can be used to download various distributions for WSL. The progress bar can be muted by changing the progress preference variable $ProgressPreference = *silentlyContiinue''; this will download the package quicker without any progress bar pop ups on your console, and in PowerShell v5.1 and lower, this can improve the speed of downloads. Launch a PowerShell console with administrative privileges and copy-paste the following code snippet, and then hit Enter to execute it. Listing 2-1. Downloading Linux (Ubuntu 18.04) distribution using PowerShell SURL = "https: //aka.ms/ws]-ubuntu-1804" $Filename = "§(Split-Path $URL -Leaf).appx” SProgressPreference = 'SilentlyContinue’ # starts download from the URL SParans = @{ URI = SURL OutFile = $Filenane UseBasicParsing = $true } Invoke-WebRequest @Parans # invoking the application package # to start the installation Invoke-Ttem $FileName Running this code will download the Ubuntu 18.04 LTS application asa file: ws1- ubuntu-1804. appx. Once the download is complete, you can use Invoke-Item Cmdlet lation GUI, on the .appx file in the current working directory to run the application and then click next to install as shown in Figure 2-9, 26 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Install Ubuntu 18.04? Pubianer Canon! Group mites ‘erin: 180420768170 ‘capaiies 1 tae ten ety Im Figure 2-9. Click next to begin distro installation Alternatively, all of the web URLs can be iterated and downloaded one by one using the PowerShell cmadlet Add-AppxPackage to add each application package (*.appx) to the user account (Listing 2-2). Listing 2-2. Adding all Linux distribution packages to user account SURLs = @( https: //aka.ms/ws1-ubuntu-1804",, "https: //aka.ms/ws1-ubuntu-1804-arn", "https: //aka.ms/ws]-ubuntu-1604", "https: //aka.ms/ws1-debian-gnulinux", "https: //aka.ms/ws1-kali-Linux", "https: //aka.ms/wsl-opensuse-42", "https: //aka.ms/ws]-sles-12" ) $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = ‘Stop’ 27 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Foreach(SURL in SURLs){ $Filename = "$(Split-Path SURL -Leaf).appx" Wirite-Host "Downloading: $Filename" -Foreground Yellow -NoNewline try{ Sparams = @{ Uri = SURL Outfile = $Filename UseBasicParsing = $true } Invoke-WebRequest @parans Add-AppxPackage -Path $Filename if ($2){ Write-Host " Done" -Foreground Green } t catch Write-Host " Failed” -Foreground Red t Ifthe PowerShell code is executed, it wll install al the Linux distributions one by one as shown in Figure 2-10, and you can also verify that by going to the Start menu and checking the recently added applications 28 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP vsl-ubuntu-t804.appx Done 4 ws ubuntu 04 are- op Done eee seeseresincae Ssl-debian-gnulinix. appx Ooo ‘el-kali-Linux. appx Core reese a feet ieee (eet Cd ©) 20vene =a eee Peete Figure 2-10. Linux distributions will appear in the Start menu Downloading Using curl.exe curl .exe pronounced “curl” is a very popular open source command-line utility that is used to perform web requests and transfer data from the command line. curl .exe can be used with a URL to download the WSL distribution package to the local machine: curl.exe -L -o wsl-kali-linux.appx https: //aka.ms/wsl-kali-Linux 29 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Figure 2-11 demonstrates that once we run curlexe with a direct URL to a Linux distribution package, it will download the package and save it on the local path which is passed an argument to “-o” parameter like ws]-kali-linux. appx in our example; this output file name can be customized if required, and the output would be written to a new file. Using cur] .exe is beneficial when you are using download and setup of WSL in a bash script, where PowerShell cmadlets we used in previous subsections won't work. BB paminintoe Windows Powers PS D=\> PS D:\> curl.exe -L -o wsl-kali-linux.appx https: //aka.ms/ws1-kali-Linux %Total % Received % Xferd Average Speed Tine Time Time Current Dload Upload Total Spent Left Speed 0 8 © 8 © 0 2@ e 108 1724 100 172" «8 =O 217k PS D:\> PS D:\> Get-Alias curl 309k Commandtype Name Version Source Alias curl -> Invoke-WebReauest PS D:\> Figure 2-11. Using curl to download Linux distribution packages Note We are running curl.exe, not curl, because in PowerShell, curl is also an alias of the Invoke-WebRequest cmdlet, which are altogether different things. Setting Up and Configuring WSL In the previous section, we learned various approaches to downloading and installing the Windows Subsystem for Linux on our system, The next things to learn how to prepare and configure WSL for first-time use, but before that, let's look into various methods to launch a Linux distribution running in the Windows Subsystem for Linux. 30 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Launching the Distro A distribution-specific executable and even using wsl.exe. Let's look into each of these approaches one at a time. ux distro can be launched as an installed application or by running the Linux Using the Application So, to begin with, go to the Start menu and type the name of the distribution like “Ubuntu” as shown in Figure 2-12. Bat ops Docu ings Web Best mateh Bens 5 a = Ubuntu 18.04 LTS 1B buntu 16.04 urs > 299 store BE veunt > ct opm Search the wb © Runa sminiraor 2 ubuntu see web reas > Pitot 2 Ubuntu philosophy -Picsphy > Pitotabee @ Ap satiogs P ubuntu download ae JS Rate and review 2 bunt B04 > swe 2 ubuntu google W vies © vountu mate > P ubuntu download for windows 10 P ubuntu Figure 2-12. Go to the Start menu and search for name of Linux distribution 31 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Now, double-click the Ubuntu application like the one highlighted in Figure 2-12 to Jaunch the Windows Subsystem for Linux for the first time. It will prompt you to wait for a few minutes while it prepares and initializes the distro for the first use. Using wsl.exe WSL distributions can also be launched though ws1.exe; ifyou run this executable without any parameters, then it will launch the default distribution package as demonstrated in Figure 2- i peateck: mnie Anux Distributions: kali-Linux >wsl exe Prateek@:/ant/c§ cat /etc/os-release Nave="ubuntu™ VERSTON="18.04.2 LTS (Bionic Beaver)” TO-ubuntu 10_LIkEsdebian PRETTY MAME="Ubuntu 18.04.2 LTS" VERSION_10-"18.04" WOME_URL="https://imay.ubuntu.com/* SUPPORT _URL="https://help.ubuntu.com/* BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/” PRIVACY POLICY _URL="https: //w.ubuntu.con/ legal/teras- \VERSION_CODENANE-bionic ‘UBUNTU _CODENAME=bionic prateek@:/ant/c$ Figure 2-13. Launching the default Linux distribution using wslexe To list all the distribution packages installed on your system and identify the default distribution, run the ws] executable with --List or-1: wsl.exe -list wsl.exe -1 Often it will be required to run a specific distribution package; in such scenarios, we can utilize the --distribution or -d parameters as shown in Figure 2-14 with the wsl. exe and pass the name of distro as an argument, as demonstrated in Listing: 32 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Listing 2-3. Running a specific Linux distribution C:\pwsl exe -1 Windows Subsystem for Linux Distributions: Ubuntu-18.04 (Default) openSUSE-42 SLES-12 kali-Linux C:\pwsl.exe --distribution kali-Linux C:\pwsl.exe -d sles-12 Bl prateek@ Thinkpad: /mmnte :\puslexe -1 Windows Subsystem for Linux Distributions: Ubuntu-18.64 (Default) ‘opensUSE-42 SLes-12 kali-Linux C:\owsl.exe --distribution kali-linux prateekiThinkpad:/nnt/c$ cat /etc/os-release | grep “NAME” PRETTY NANE="Kali GWU/Linux Rolling” NANE="Kali GNU/Linux” prateek@Thinkpad: /mnt/c$ [BH SUSE Linu Enterprice Server 12 P3 root Thinkpad: mnt/e c:\>wsl-exe -1 Windows Subsystem for Linux Distributions: Ubuntu-18.e4 (Default) ‘opensUSE-42 SLES-12 kali-Linux Pee c:\pusl.exe -d sles-12 Thinkpad:/ant/c # cat /etc/os-release NAME="SLES™ VERSION="12-SP3" VERSION_1D="12.3" PRETTY HANE-"SUSE Linux Enterprise Server 12 SP3” 10="sles™ ANST_COLOR="0;32" ‘CPE_RAME~"epe: Thinkpad: /ant/c # ser sles: Figure 2-14. Launching a specific Linux distribution using wslexe 33 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP ‘We will look into other capabilities and command-line arguments that ws1.exe accepts in detail later in this book; for now, let's just understand a few important pointers about invoking a Linux distro using ws1..exe like this: 1, WSL launches the distro in the current working directory of the CMD or PowerShell prompt. 2. A Linux distribution invoked through wslexe will run as the default user of that distro, but you can change that behavior using -user or -u parameter by passing the name of specific user as an argument: wsl.exe distribution Ubuntu-18.04 --user prateck 3. The Linux distribution invoked through wsl.exe will have the same Windows administrative rights as the calling process and terminal. Using the Executable All the Linux distributions can also be easily launched directly using their respective executables as demonstrated in Figure 2-15, which are all placed in the folder “C:\Users\{username}\AppData\Local\ Microsoft\WindowsApps\" and here are few examples in Listing 2-4 which you can try yourself Listing 2-4, Running a Linux distribution through its executable # Launching ubuntu 18.04 ubuntui804. exe # launching kali Linux kali.exe # Launching openSUSE 42 openSUSE-42. exe 34 eyams.ee ee prateetd pratecks:-§ cat /etc/os-release CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP So ad # cat fete/os-release ane="Ubuntu™ Juie-“opensuse Leap” VeRsioN"18.08.2 LTS (Btente Seaver)’ feRSTON- "42.3" rubuntu lro-opensuse To_LiKe-debian fp. viKes"suse™ PRETTY-AARE="Ubuntu 18.06.2 LTS fERSIOH 10-4237 VERSTOW_10="18.04" >RETTY_HUANE=" openSUSE Leap 42.3" HOME URC="https://tan ubuntu. com/" puist_coLon="0;52" ‘SupPORT_URL="https://help.ubuntu.con/” PE_RaNE~"cpe:/o:0pensuse: 199342. 18UG_REPORT _URL="hetps://bugs.launchpad.net/ub4_UG- PRIVACY POLICY URL="https:/ fu. ubuntu com/esFONE_ URL= Bl pate Tintpas- lrt>kans exe ie Prstectainiskpest-s retecgrnintpad:c6 cat etc/onoreleare Perry. anesntali Cn/tinox noliing fives"eans einen fsa asta" 2019.2° fst cove 237 nein": //okaldore/™ pnr-ontsshtige enamel org/* vc, nont-onte"Reeps/ ga tali-org/= ‘Sheeps:/ bugs opensuse org” ittps://omy.opensuse. org!” Figure 2-15. Launching distros using executables In this subsection, we learned various approaches to run a Linux distribution in WSL, but when a Linux distribution is invoked for the first time, the first setup prompts the user to create a user account; le’s look into it and learn how to manage user accounts in WSL. Setting Up and Managing User Account ‘The creation of a user is the first step in setting up a new Linux distribution on WSL, so as soon the initialization is complete as seen in Figure 2-16, it will prompt you to create a new user account with a password. This user account is automatically configured as the default user of the distribution and added to the “sudo” group as a Linux administrator. ‘The user configuration is required every time you install, reinstall, or reset a distribution. CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Note When the password is entered, it is not echoed to the console for security reasons, and this doesn't mean the system is not receiving the keystrokes. @ prateek@ Thinkpad: ~ Itnstalling, this may take a few minutes... Please create a default UNIX user account. The username does not need to For more information visit: https://aka.ms/wslusers Enter new UNIX username: prateek lenter new UNIX password Retype new UNIX password: passud: password updated successfully Installation successful! fo run a command as administrator (user “root"), use “sudo ". "man sudo_root" for details. prateek@Thinkpad:~$ cat /etc/group | grep sudo |sudo:x:27:prateek prateek@Thinkpad:~$ Figure 2-16, User account setup during distro initialization By default, the password is not required when you launch the distro, but it will be required when you are elevating the privilege of any process using the “sudo” command. ‘To change your current user password in Linux, open your Linux distribution (eg., Ubuntu) and enter the command passwd, and as shown in Figure 2-17, you will be prompted. to enter your current password, and once you supply that, it will again ask for confirmation. @ prateek@ Thinkpad: prateekéThinkpad:~$ lprateek@thinkpad:~$ passwd bare password for prateek. (current) UNIX password: [enter new UNIX password: Retype new UNIX password: passud: password updated successfully prateeksthinkpad:~$ . Figure 2-17. Resetting a password 36 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP In case you've forgotten your password for any specific Linux distributions, open. PowerShell or the “Command Prompt” from the Start menu and run it as the root on the target WSL distribution using the following command: ws -u root -d Once your WSI. distribution has been run with the root user, go ahead and use the passwd command with the name of the user for whom you want to reset the password, like in the following example: passwd prateek Ifyou don’t use the root user, you won't have enough privileges to reset the password for any other user, without entering their current password which we forgot in the first place. Permission Model Unix users in the Windows Subsystem for Linux are non-Windows user accounts that are independent of the Windows permission model that will be required to elevate privileges in your Linux distribution. There are two separate permission models in WSL for Linux and Windows, and they are independent of each other, That means an admin Linux user will only have elevated privileges in the Linux environment and permissions in Linux will not work in Windows. ‘The catch is since the WSL is launched and initialized by a Windows user account, any Windows resources on which this Windows user account has access to will be also accessible from inside the Windows Subsystem for Linux. ‘As demonstrated in Figure 2-18, we can easily access the mount points in the Linux environment, which are nothing but Windows drives mounted on the Windows Subsystem for Linux. When the current Windows user runs “Is” command on a directory which is accessible to them and then pipes the result to the “we -I" command to get the number of lines returned, we observe that the count is more than zero, but ifthe current ‘user attempts to access any other directory where they don’t have proper permissions, then zero results will be returned. This proves the preceding point that even though you are working in the Linux subsystem, the Windows permissions are applied on the Windows resources you are accessing. 37 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP ‘But when I ry to access a Windows directory I don’thave permissions for, it fails with, “Permission denied” error. This happens because the Windows user “Prateek” through which WSI. is launched has access to its user profile folder C:\Users\ Prateek: THINKPAD buthas no privileges for the user profile folder of ‘Administrator’. e prateek@Thinkpad:~$ prateek@Thinkpad:~$ 1s /mnt/c/Users/Prateek.THINKPAD/ | we -1 41 Prateek@Thinkpad:~$ 1s /mnt/c/Users/Adninistrator/ | we -1 cannot open directory '/mnt/c/Users/Administrator/‘: Permission denied rarnesont 4 7 A CAWNDOWSystem32\emexe licrosoft Windows [Version 10.0.18362.592] a (c) 2019 Microsoft Corporation. All rights reserve (C: \Users\Prateek. THINKPAD>whoami hinkpad\prateek Figure 2-18. Permission model restrictions Updating and Upgrading the Distro Now we know how to install WSL and initialize it for first use, but even though you did a fresh install, itis highly likely that some of the default packages and tools that come with your Linux distribution are a little outdated and new versions of these exist. So, we need a mechanism to update them to the latest versions, because those are most stable and come bug fixes and security improvements. Note For the sake of simplicity to the readers, we are working under an assumption that you are using Ubuntu or Debian Linux distributions, which are two most popular distributions. if you are using any other Linux distributions, then the following commands to update/upgrade may not apply for you. 38 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP First things first, before jumping into how to do that, let's first understand the general difference between update and upgrade. An upgrade is the act of replacing the current product with a newer and more superior version of the product, whereas an update modifies your current product. In Linux terms, more specifically to Ubuntu and Debian, “update” means to refresh the list of packages installed, like bumping up the versions and so on without modifying anything else, and “upgrade” means to install any updates to the list of installed packages. Almost all distros are lightweight minimal software packages that can be quickly downloaded and initialized; they have only the necessary tools and libraries shipped with them. Itis a good idea to update and upgrade your distro using the following, command in Listing 2-5; please note that this step may take a while to finish, and you will see packages getting downloaded like in Figure 2-19. Listing 2-5. Updating and upgrading the Windows Subsystem for Linux sudo apt update && sudo apt upgrade Orme rateek:-$ sudo apt update && sudo apt 21 http://eecurity-vbuntscon/sbuntu blonic-security TnRelease [88.7 k8] 1:2 http: /Jarchive-buntu.cos/ubuntu bionic TnRelease 3 hetp://erehive ubuntU.coe/Ubunt Bionic-updates Infeleose [68.7 kB) htt://archive ubuntu-cow/abuntu bionic-beckports TnRelease [74.6 KB) hetp://archive-ubuntu-cow/ubuntu bionic/universe anda Packages [8570 kB) 4:6 http://seeurity-sbunts.con/sbunty bionic-security/main ond6a Packages [448 KO) 17 hetp://security ubuntu, con/ubuntu bionie-security/main Translation-en [136 8) 8 http://security ubuntu.con/ubuntu bionic-security universe and64 Packages (570 kB] 1:9 http: //security bunts con/sbunts bionie-security/universe Translation en [185 KB) fax (8 Packages store 0 8} [5 Packages 1188 K8/8570 kB 14x} [9 Translation-en 35.7 K9/18S kE 20K) Figure 2-19. Update/upgrade WSL distro In Figure 2-19, apt stands for “Advanced Package Tool,’ and apt is a command- line tool which helps in handling packages on Ubuntu, Debian, and related Linux distributions. apt interacts with Ubuntu and Debian packaging systems to find and install new packages and to upgrade or remove packages. But there is a common misconception that apt update installs the new version updates of software packages on Linux, which is not the case. Instead, it updates the database called the apt package index, which keeps a list of available packages from the distro’s software repositories in the '/etc/apt/sources.list file. 39 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP For example, if you have Python v3.5 installed then after apt update, the aforementioned database will be aware that a newer version of Python exists, version 3.6, and is available, Now when you run apt upgrade, it will upgrade Python v3.5 to the newer version. But the story doesn't end here, and as a developer, you will stil need other tools and packages in your Linux distribution for various reasons; so now we will look {nto installing additional software on your Windows Subsystem for Linux in the next subsection. Installing Additional Tools and Packages ‘The real purpose of having a Windows Subsystem for Linuxis to enable developers to use their favorite Linux tools in Windows to enhance their overall development experience. Just like any flavor of the Linux operating system, on the Windows Subsystem for Linux, most of these Linux utilities, tools, and packages can be easily installed using a package ‘manager like apt which is a collection of tools to manage packages. In the following, ‘example, we are installing nodejs, git, and nmap on our Linux distribution using the apt instal] command sudo apt install nodejs git nmap APTis a collection of tools like apt, apt-get, and apt-cache which brings a little more to the table, like the ability to search for packages using the apt-cache search by specifying a search keyword, and it can even check the detailed information of the package like Architecture, Size, MD5 checksum, and so on using the apt-cacke show command as demonstrated in Figure 2 apt-cache search aws-cli apt-cache show python3-botocore 40 CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP @praesorninipa — prateek@Thinkpad:~$ prateeksThinkpad:~$ apt-cache search aws-cli Python-botocore - Low-level, data-driven core of boto 3 (Python 2) python3-botocore - Low-level, data-driven core of boto 3 (Python 3) prateek@Thinkpad:~$ prateekThinkpad:~$ apt-cache show python3-botocore Package: python3-botocore Architecture: all Version: 1.8.48¢repack-1 Priority: optional Section: universe/python Source: python-botocore Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Python Modules Team = 3 Filenane: pool/universe/p/python-botocore/python3-botocor Size: 1764396 MDSsun: ce61c81a93e4197be@dcFo3acFbBa5e2 SHA1: 642079815514036b59065#2312612535a7#80a73 SHA2S6: cd0ac5¥e4636f23401a3b67331bad4697a74ecf6256d8e73dFbd4498F467¢8ab Homepage: https: //github.com/bote/botacore Description-en: Low-level, data-driven core of boto 3 (Python 3) ‘A low-level interface to a growing number of Anazon Web Services. The botocore package is the foundation for AWS-CLT. ‘This package contains the module for Python 3. Description-nd5: sbfe6z0f1a2dee565164398a617b5493 prateeksThinkpad:~$ sudo apt install python3-botocore Reading package lists... Done Building dependency tree Reading state information... Done The follwing package was autonatically installed and is no longer required: Libdunbnet2 Use ‘sudo apt autorenove’ to renove it. The following additional packages will be installed: Figure 2-20. Search and install packages using apt al CHAPTER 2 DOWNLOADING, INSTALLATION, AND SETUP Summary In this chapter, we learned how to enable the Windows Subsystem for Linux on Windows 10 systems and various methods to download and install the Linux distribution. Once that was done, we launched the Windows Subsystem for Linux for first use, followed by setup, configuration, and user management. Going forward in the next chapter, we are going to learn to build mixed experience between Windows and Linux environments by worlds to developers and system administrators. dging the gap between the two operating systems and providing the best of two 42.

You might also like