Install WSL2 - Complete Beginner Guide (+Windows Terminal Setup!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys what's up everyone welcome back to a new video it's been a while but i've been getting a lot of questions lately about wsl2 and how i use wsl 2 to write code and to do penetration testing and all this kind of stuff a lot of you know that i almost exclusively use wsl too i'm not using any kind of linux distributions anymore be it a virtual machine or bare metal i almost exclusively use 2 for programming as well as for penetration testing so for this video i kind of want to pick it up from the very beginning so i'm going to show you how to install wsl 2 on windows and there are two different methods of going about that which i will show you in a second there is a very quick and easy way there is a little prequisite to that which is you need to be on the latest version of a windows 10 or you need to run windows 11 and then there is the manual approach for all the versions of windows and we will cover both of those approaches in this very video as well as there's a little bonus on top of that all where i will show you how to install windows terminal which is basically the command line that you are using instead of the default wsl2 command line that comes pre shipped with installing wsl2 or any kind of linux distribution but it really kind of sucks so i want to show you a better way on how to use and utilize the power of windows terminal which is a really really nice terminal emulator so we are going to cover all of this in this video get ready and let's go should you feel more comfortable to have a written piece with written instructions where you can copy and paste the code we will go over in this video open next to you you can go to cosec.com or click in the link in the video description below to open the written article and then you can just follow along with the steps and it's everything is very well structured here with screenshots um but the main thing is that you can go ahead and copy those commands if you want to so before we get started what actually is wsl and wsl2 what is the difference and so on and so forth so wsl is basically a terminal that you run or it's a virtual machine a virtual linux terminal if you will that you can just run right on top of windows 10 which means if i click on my ready to use it's i already have it installed because i'm personally using it and i'm using windows terminal as i've mentioned so if i click on this here my ubuntu 20.04 will take a couple of seconds to boot up so this is booting up the vm in the background and there we go that's it and this is a full-fledged linux vm running ubuntu 2004 and i can do everything that i need to do or everything that i could also do on a normal linux vm if i would install something with kali or something like a kali linux or ubuntu on virtualbox so this is exactly the same thing i can do nmap which is probably not installed but i could if it would be on there i just freshly reinstalled that so there's nothing on it really but i can do all things i could do on a full fledged linux vm with just a click of a button and with a terminal window now there are differences between wsl2 and wsl1 and wsl2 so i really recommend you to use wsl 2 simply because you have way more features available to you which you can see here there's the comparison of those features and one of the biggest things obviously is the 2 has full linux kernel support as well as full system call compatibility there was a big caveat in using wsl1 because you were not able to run something like nmap or any network layer based tools so there was a huge huge thing that was missing on it and now with wsl 2 all that is integrated it's super lightning fast and it's really really nice on top of that uh we can also just use it to do our coding or web development which i generally do as a deli driver i use wsl 2 as well so if i go to my main directory of something like i'm experimenting with django and if i go in there and this is mind you i'm in linux right now yeah so i can just go in here and i can just do code dot which then automatically will open up my visual studio studio code or that folder in visual studio code and if i just want to start my virtual environment i can just do pip and shell in here and i'm in my virtual environment and i can run all of those files as you can see here we are hooked into wsl too and this is all integrated into visual studio code and this is how i did programming for the past two years specifically web development with something tools like react and stuff like this i was exclusively developing on wsl 2 using ubuntu so i think you get the idea i also do my penetration testing exclusively on a different vm i don't use kali i also use ubuntu for that so just to show you a quick overview of what is possible with wsl2 and by the way this is the fully integrated wsl2 shell here too so you don't even actually need to open this window at all you can just go here and you are in your wsl which is then integrated into visual studio code which is really amazing like it works so well uh that i really am i'm in love with this kind of setup because it works so well and everything i wanted to do there were no limitations so far whatsoever i could install whatever i wanted so this is why i really like it okay guys with that being said let's jump right into how to install wsl2 as i have mentioned previously and there are two ways to go about this if you are on a newer version of windows 10 you have it very easy to install wsl2 and you can check which version of windows you are running so i have it there in the article you need to have at least windows 10 version 2004 built 19041 or higher or you run windows 11. now how do you find out which kind of windows version you are running you just simply hit the windows key and r and then you type win version so vin ver as you can see down here in the bottom i pulled it up a little bit and then you simply click on ok to pull that up and then you can see your windows build right here so you can clearly see that i'm on a higher build than this i'm on 1990 43 and this is 1941. so as long as you're above this number you are fine to use the first method which makes it very very easy for us to do that should you be running a older version of windows and you are of some reason are not able to upgrade to a newer version then stick around for the manual steps which are following after this so you can also use the timeline below to directly go there all right so install wsl2 on windows the easiest way i'm going to pull it over to the side and actually going to show you every step so step one is you are going to open powershell in admin mode so you hit your windows key again you start to type powershell and then you right click on windows powershell and you click on run at s administrator all right and once you are in there now mind you i already have it installed there might be some hiccups some problems if there are any let me know in the comments below and i will add them later on to the video or to the article but so far i did this on multiple machines and i did not run into any issues okay now since we are here we can simply use at least in theory wsl and then minus minus install and i said in theory because this did not work for me but this is the way that is documented in the official wsl 2 documentation and what i actually had to do is i needed to choose a distribution so how you do that is you type wsl minus minus list space minus minus online and by the way after wsl is a space also and once you pull that up you can see all available uh distributions that they have now let's say you want to install ubuntu 2004 you have to exactly type in this name so you have to type in ubuntu with a capital capital u minus 20.04 and so on and so forth you get the idea so to actually do it then you do wsl space minus minus install minus d for distribution and then if you wanted ubuntu as i said you need to type it exactly as it is like so i already have you won't install so i'm going to choose debian as you can see kali linux is also available there so you can play around with that too it's quite a fun thing to play with um and once you are there then you want to hit your enter key and once you do that it's going ahead and it's downloading the debian image and let's give that a couple of seconds to finish and now it's installing and then it will ask you for a username so this is your username that you want to use for wsl so i'm going to choose my name stefan and then we are choosing a password of course and this is the way how you will log in and that's how quickly you have installed wsl now there might be a requirement while you are typing in this command that it will install something that you do not have installed yet or it will activate some virtual machine features so there is the possibility that you will get prompted to restart your computer that it will not be that fast because i already have everything set up so there might be a prompt for you to restart and should you get that just do that and then it should pick up right where you left off once you logged in back to windows now the next thing we need to do is we need to check our wsl version if we are in fact on wsl version 2 and we can do that by going back to powershell and typing wsl space minus minus list space minus minus verbose as soon as you did that you can see that this is in fact both running on wsl version 2. this is it guys this is how you install wsl 2 in the easy way now we are going to cover the manual way which goes through every step of activating the virtual machine features and all that kind of jazz manually now if you did run into any problems using this new and easy way that supposedly work according to microsoft on every system which i doubt because every system has a different configuration so if that first easy way did not work for you guys follow through with the manual way because this will work for sure let's dive right in and also make sure to stick around until the end of the video because then i will show you how to install windows terminal okay i just went ahead and i removed dbn again so we can go ahead and reinstall it so i'm going to clear everything up and we're going to start from scratch now the first thing we need to do is obviously open powershell again if you haven't opened it yet hit your windows key type in powershell right click powershell click run as administrator all right so once we have done that we need to enable the wsl feature by typing in and i'm going to copy and paste that from the cosec.com article i'm going to paste that in here and if you want to type that feel free to do so but i recommend you to pull up the article and just copy and paste it you will find that underneath of install wsl2 on windows the manual way step one i quickly pulled it over for you that you can see it there it is step one enabling the wsl feature and right here you find your command to copy and paste and once you have that pasted in obviously just hit the button and because i already have that enabled uh it's very quickly done now you might get prompted to reboot your machine after putting in this command if you get prompted for that just go ahead and do it again the features or the requirements for wsl2 in general are in fact you need to be on windows version 1903 or higher with the build version 18362 or higher okay so if you are below this version i'm going to pull it over for you again because i have it open on my second screen so this is what i'm talking about if you are below this version wsl 2 will not work for you at all so make sure you understand that before asking any questions in the comments all right there we go now step 3 is enabling the virtual machine feature of windows and again we have another command to paste in here i'll give you a couple of seconds you can stop the video and type it in manually if you choose so a better way is to open up the article all right and once you have that in hit enter again will be pretty quickly too and definitely after this step you have to restart your computer otherwise it will not work okay once we have that once you have restarted your computer it's time to update the linux kernel and to do that again i put the article over here it's on step four update updating the linux kernel there is the link to the official microsoft source to download the kernel if you do not trust this link itself it's the link from the official documentation just google for wsl 2 linux kernel and you will end up on the same website where you can download it but this is the official source anyway okay once you have installed that there's only one more thing we need to do which is we need to set up wsl 2 as our default ws version because if we do not do that every distribution you will install will per default install on wsl one and then you would need to go ahead and manually update or upgrade actually my grade is the correct word migrate those distributions every single time you install something you need to migrate it over to wsl 2 which is a very tedious and time intensive task so i highly recommend you to uh set your default wsl version to version two and that's what we're gonna do now so we're in we are in powershell still right so we do wsl space minus minus set minus default minus version and space and a2 boom operation completed successfully and then we have it there okay so how do you actually install a distribution via the windows store because so far we just have installed it as you have seen in the steps for the first way that i've shown you so we can go ahead and we can list that up again so we can list all the available distributions like so and then we can do the same thing like we did before we can do wsl minus minus install minus d and then we have to type in this exact name and if you want to install ubuntu again uh with the capitalization in mind and as well as the version number you just put it in there you hit enter and it's gonna install it like it did before but there is another way of doing that you can go to the microsoft store or to the windows store whatever the name is so just hit the windows key type in store and you will eventually end up in at the microsoft store if we open that up somewhere it opened up okay so it's here and then you can just search for debian or ubuntu or whatever you want and you will end up right there on this page now first probably for you there is a get and after you click on get you can click on install much like in the app store on the ios store and once you click on install it's gonna pull that down for you and it's gonna install it within a couple of seconds i just love how fast it is we just installed linux guys within five seconds not even that click on launch and you can always launch your distributions by hitting the windows key and then typing in debian for example and this is that but in a second i show you a better way of starting your distributions anyway so just stick around for that all right same thing again enter username my name again save password boom that's it literally installed linux within 10 seconds there we go and to make sure we are on version 2 in fact we can go ahead and do again wsl in powershell mind you minus minus list minus minus verbose and we are in fact on uh wsl version two so now you are completely set up and you are good to go if you want to use a shitty terminal that is doing uh let me show you or that sometimes even stucks right let's get that open again and if you want a terminal that is like not working really well and is doing a lot of weird sound sometimes when it finds a command that is not really there um then go ahead and and use this but i highly recommend you to install windows terminal windows terminal is a terminal emulator from microsoft because they realized that this is sorry for the language and they provided a different uh or a alternative to that so go to the windows store and type in windows terminal and once you type that in you see windows terminal fairly good reviews here on the windows store microsoft store so click on it and click on get and click on install yeah and once that is installed just launch it now i recommend you to just go ahead and do i press the windows key windows terminal this looks like a little bit of a broken app icon here but this is in fact the windows terminal that looks like this just right click it and do pin to taskbar right so you always have it in your taskbar for quick access you can also go ahead and close the window of powershell and uh yeah the next thing is we're just gonna open windows terminal you probably have that open and as you can see i immediately end up inside of my ubuntu whereas you will probably end up somewhere in powershell this is exactly what we're gonna fix next so the thing is you can go here on this little error arrow not error and you can switch all of the available things here so you can directly switch or you can create a new window and you can do powershell so you have a powershell window open and your ubuntu or 15 different distributions we can open another window which is a window with debian so now we have ubuntu and debian next to each other and this is probably not debian it looks weird oh it's deviant okay it just has the same sign here um so you have both distributions next to each other you can open multiple of those windows you can set that all up uh to split the screen and stuff but this is this is something for what i want to show you in a later video the only thing i want to show you now is click on this arrow again and then go down to settings or you can check out the command palette which i would recommend you because a lot of important uh keyboard shortcuts there click on settings and then while you're on the startup menu on the left you want to change your default profile to ubuntu or whatever distribution you choose for and i just recommend you to look through here because it's really interesting what you can change directly with the windows terminal settings you can change the color you can make the background nice and blurry which i will show you in a later video too i have a really nice wsl two setup with a like a transparent background stuff like this you will really like it so look forward for the next video there but you can you can just go through this and you can see all the commands and stuff like this so i'm really fluent with it i can pop up windows left and right and split the screen and stuff like this all with keyboard shortcuts and once you get used to that it's really nice but you can change also the font size and stuff like this then don't forget to click on save and let's close that all up and as i have already showed you when i open wsl now it's directly defaulting to ubuntu and then if you type cd you end up in your home directory now this is the mount directory of wsl and um yeah this is basically the directory that refers to your windows directory or to the ubuntu destination on windows you can also utilize something like wsl path which will show you the wsl path on windows if you do minus w and then a dot for the current directory and this is actually your translated path to windows so if you would put this path into your file explorer you would end up in this folder there all right guys i think this is really all i wanted to say for this first video this introduction video to wsl2 once again i really love wsl2 which you probably know by or after watching this video it's a really great tool i really love to work with it both in penetration testing as well as in programming and web development now as i said during the video i will show you some wsl customizations we will install that as age we will do a nice uh translucent or transparent background for our wsl console and i show you how to install different fonts and to make look to make windows terminal look a little bit nicer overall so it's more pleasant for the eye but in the meanwhile i recommend you to play around with it download vs code play around with that with the vs code integration it's really great especially if you're a web developer let me know what you think about that in the comments below guys let me know if you want to learn anything specific when it comes to wsl 2 and make sure to check on the blog regularly for updates on the wsl 2 series and i hope to see you back in the next one guys thanks for watching it's nice to be back see you soon you
Info
Channel: Stefan Rows
Views: 2,075
Rating: undefined out of 5
Keywords: install wsl2, wsl2 install, wsl2 installation is incomplete, windows wsl 2, wsl2 windows 10, wsl2 ubuntu, windows 10 wsl2, upgrade wsl to wsl2, install wsl2 windows 10, wsl2 update, install wsl2 on windows 10, wsl2 download, wsl 2 requires an update to its kernel component, ubuntu wsl2, wsl2 ubuntu desktop, update wsl to wsl2, windows install wsl2, windows10 wsl2, enable wsl2 windows 10, wsl2 install windows 10, download wsl 2, windows wsl2 install, wsl2 kali linux
Id: VMZH9Pj2dXw
Channel Id: undefined
Length: 23min 32sec (1412 seconds)
Published: Tue Sep 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.