The Ultimate #WSL2 Guide - Part 2 - Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey vlad here devinsideu.com welcome to the second and last part of the wsl series in the previous video we have seen my setup and today we're going to replicate it step by step let's get right to it all right now before we get into it i actually created a gist well actually it's not just it's a part of a sort of old learning resources repository it's one file and the link is going to be down in the description was all the written down instructions of everything that we're going to do today we have the windows tabs we have the linux styles we even have a couple of um visual studio code steps okay the link is going to be down in the description all right so the first thing that we're going to do is we're going to check the windows version that we have now microsoft back ports features from time to time so features even even big fixtures like like wsl so checking the version is not super important but still since i'm already recording a tutorial let's do this the easiest way to do this is by pressing windows r and typing in ven ver as in windows version the windows version looks kind of weird and the first number is when it was released or technically when it was supposed to be released and this is not the year 2004 this is the year 2020 and the fourth month which is april but technically they released it at the end of may uh there were actually a lot of bugs related to it but this is not the number that we actually care about we care about um these two numbers all right and microsoft back ported wsl so what you should see here is at least 18362 i believe or 18363 and this number should be at least one zero four nine another thing you could check is by typing dx diag as in directx diagnostics and this window will pop up and you should check that you have a 64-bit uh windows version and you see here the build number again and over here as well i'm not sure what this zero four eight eight is uh because it's not the number that we're seeing over here all right but in any case whatever numbers you are seeing there just go and try to enable wsl and there are several ways to do it you can just open the start menu and start typing something like turn and you should see some like turn windows features on and on or off you can just open it it looks like this or you just do windows r and type in optional optional features and exactly the same windows should pop up now i'm going to double click over here so that it's bigger now for wso 1 you need to enable windows subsystem for linux which is this one for wsl2 you also need to enable the um where is it the virtual machine platform and if you're on a pro version again you can check this over here and then where you can see that i have the pro version uh you might also want to enable hyper v you might actually need to enable hyper v okay if you're in the home edition uh hyper v is not going to be available um however as soon as you enable the virtual machine platform it should still work uh work just fine then just press ok and if windows is going to detect any changes you're going to be asked to restart and you should as a reminder you can run only one hypervisor you know a hyper v is a hypervisor you can run only one of them and as a reminder you know if you're still playing with virtualbox like i was you know this is like a migration guide then as a reminder over here you need to be able to you need to be sure to uh select the hype of the power virtualization as well you do this by right clicking going into the settings clicking on system going to acceleration and changing it from it's probably going to be default changing it to hyper v and as i already mentioned in the previous video this makes the virtual machines pretty much unusable but at least this is the only way how they will even even boot and hopefully this will improve in the future uh another side note if you're uh sort of hopping back and forth uh like for example what i was doing is i actually you know because hyper v was like making it so unusable i actually left it on default which is kvm i believe and then i was basically going back and forth and like disabling those flags uh you know rebooting it sort of felt like i was dual booting okay and going back and so what i want to say is that sometimes for some reason one reboot is not enough right so sometimes you know like i rebooted once and then my my vm wouldn't start and i got scared but then i just rebooted again because you know microsoft and then it worked okay right so uh the next thing that we're going to do is we're going to go and and just install one of them okay so there are multiple ways to do this but the preferred way is to go through the windows store you can actually go to the documentation for um you know for for wsl and there will be like a list was was portable versions uh was why did i say portable i think that's what the section was saying anyway there will be like a list of the versions however this list is shorter than what you can find in the windows store so if you go to store microsoft store then you can click on search and just type in wsl start the search and we should find a couple of distributions and we're going to go with ubuntu 2004 ltes today but as you can see there are others and uh some of them i believe actually cost something um let's see i saw something somewhere that um that costed something um doesn't really matter today we're gonna go with ubuntu 2004 lts so if you click over here um the uh button as you can see it was saying install or sometimes it says get and now it says launch even though i don't have it installed okay so if i open the windows terminal and if i do wsl v then you're going to see that uh none of them are called ubuntu 2004 okay this is by the way as a reminder from the previous video um this is how well actually maybe i didn't mention it but this is how um windows note windows compares them to each other right so if it sees that that the name is already taken then it thinks that it's already installed now what we're seeing over here is actually a bug in the store in fact if i click on launch it's actually going to start installing it okay so this is just a bug and in fact there is a way to clear the cache of the microsoft store and i actually did it but it didn't really help okay so when we're installing it um the font is kind of small but don't worry about it we're going to switch the windows terminal in in any case in a couple of seconds so i'm going to call my my user just vlad and i'm going to create a password confirm the password and there we go we're inside okay so um the first thing that i'm going to point out is the the prompt the prompt looks normal in a couple of seconds it's not going to look it's not going to look normal in a couple of seconds we're going to log in again and we're going to see that where the the user will switch to switch to the root user and i'm going to show you how to fix it okay so for now i'm just going to exit it like this as you can see the button still says launch and if you click on launch it will it will just exit like this all right let me close it again as i already mentioned in the previous video it's kind of annoying that we're not even being asked like where to install it to or uh you know like you know what what what the size of the hard drive should be you know like we're being asked nothing we just click and and bam so as already mentioned in the previous video it feels still like just a shell you know it's like this tiny thing now um it installed this thing into um here so if you go to uh user profile by the way this is how you access environment variables in windows by using the percent symbol in the beginning and the percent symbol in the in the end so if you go over here and if you just sort them by date modified and in this case it's ubuntu by the you know canonical group limited which is why we're seeing over here canonical group limited ubuntu 24 on windows if we go in there and if we go into i believe local state we're going to see ext4vhdx right now this shows us that this is already um the wsl2 version in fact if i open a terminal i'm going to use windows terminal and if i do if i do this again we're seeing that the version is is two okay also you can at any point in time you can do wsl uh have an h to see the help and as you can see you can set set the default version and because i set the default version to two what we just installed was the second version and i saw it because it was a virtual hard drive i'm sorry i was pointing at the wrong ones here the set default version this is like the set default distribution as a reminder like in my case the default distribution is space all right let's exit from here and um i want to check the the size as we can see it's like around around one gig right so this is like the the minimal uh minimal version of um ubuntu and the first thing we're gonna do like even like before we sort of uh before we like properly go into it uh we're gonna move it okay so um let me go into the windows terminal again and i'm gonna do this okay so it's over here ubuntu 2004 and it's stopped like as you can see like all of them are our stop by the way i should probably also show you how to install the windows terminal you just go to the microsoft store which we already have over here i just type in windows terminal windows terminal okay uh this one come on load as you can see first it was saying installed then i realized that i have it installed and now we've seen the launch button so if i press it it's going to be it's going to be over here and you can also find it under um under the same deal so it's over here local but then you need to go into into microsoft microsoft and inside of microsoft you're going to see you know windows apps over here and over here this is the wwe and wt exe and this entire folder is actually on the path so at any point in time which is what i was doing before i would just type in wt and it was just starting this exe okay now it is always starting in full screen so let me actually do this i want to show you a couple more things so one of the cool things about windows terminal is that it actually shows you like your um your vms over here but honestly i'm never using it because it's super simple like for example this one is called space if i want to get into it i just do w cell i haven't have d space and then bam i'm inside of it okay there we go it asks me to unlock my my key let me actually exit okay and this is how you so over here uh you see that was on verbose you see that that it's running now so you can terminate it like this with a t okay so now it's going to say that it's stopped and also you can uh let's go let's go in there again like this and yes i probably typed it wrong i know it's oh it's okay okay so again again it's running and let's actually also run another one um i forgot the thing ah the full name is live inside you down inside you like this okay and that's my key okay exit all right so again so now now two of them are running and the way you shut it down you can shut all of them down right so it just it just terminates all of them shut down okay like this right and let me go up like this and there we go all of them are stopped and as a reminder you can always do wsl negative h uh negative eight oh my god uh half an h and you can see exactly what i just did you know i did the terminate uh we're gonna do unregister in a couple of seconds all right now um about the windows terminal so this is a cool thing that i can show you this uh you can also open the settings and you can also do alt click on this and it will open the default settings and we're actually going to do this so if i'm going to do alt click it actually just open the default settings on my second screen and sublime as you can see it's over here i'm actually not even going to bring it over here because we're going to open it in vs code okay and i'm going to click without without holding the alt okay so now i have both of them open on my second screen and i'm just going to copy the file path and i'm going to just paste the file path over here and i'm going to remove the default.json and i'm just going to open this um this folder okay so this is this is where it is okay but like you can do exactly what it just did like it opened with sublime okay so this is the default.json what i want to show you is that if you open it actually with vs code and then you're going to get auto completion in this file okay so for example over here it says like launch mode and default and if i remove default i can do control space and it should have it should have shown me it should have shown me um auto completion i'm not sure why it doesn't maybe it's because it's the uh maybe it's because it's the default settings um discard okay hold on uh let me close this one let me actually grab um grab the other one the one that you know the the regular settings i'm gonna copy the file path close this actually we can also close this i'm gonna do paste over here okay it's in a different folder it's this file called settings.json and we're going to do the same trick open was vs code all right and now over here it should say full screen and see okay we have default full screen maximize okay so what you would usually do is you would just copy over the default settings and and by the way remember like in the previous video i said that i don't even have git installed and so uh the git lens extension uh says that it couldn't find git okay because i'm doing like all the all the development stuff i'm doing like inside of um inside of uh virtual machines before and now inside of inside of wsl so what you would usually do you would open the default settings you would copy it over to the uh to this file change all the things in fact i'm going to show you one more things one more thing that i changed is um at the bottom i have the key bindings because some of them were colliding was uh with things like viable this is how you how you disable them okay just command like null or i believe you can also use undefined okay but i don't want to focus this video on windows terminal i already spent way too much time on it okay so uh what i want to do now is i want to i want to open the windows terminal again like this so what i'm going to do is i'm going to change the directory um to the place where uh where all of my machines are which is in business and wsls okay so powershell also understands things like ls okay so these are the things that i have inside over here okay so now i'm going to do wsl have an h and we're going to look at the export command which is over here right you just export the distribution name it's the one that we that we have seen you know was the ubuntu thing and how we want to name the file okay so again okay so we want to export this one so we just say export and we're saying ubuntu 20.04 and i'm going to call it ubuntu underscore backup you can call it however you want it doesn't need an extension but you can pretty much use this as a backup okay so let me actually minimize this before um before i actually do this so we're going to go over here so this is where we are and i'm gonna actually position it like this and like this so i'm gonna press enter and it's going to start exporting it into this file over here it should take i mean it's just one gig okay so it should take i don't know maybe maybe maybe 20 seconds or so all right so as you can see it finished it's now over here and before we do anything else i actually want to go into um i believe over here was it right so i want to open this thing okay and i want to um well actually i don't want to i don't want to open it yet okay so i want to have it like this it went to my second screen so i want to have it like this so what i want to do now is i want to call the uh on the register function okay because we don't need it like we're moving it okay so i'm just gonna do uh unregister and i'm gonna do ubuntu on 2004. okay so what i want to show you is that this folder is still going to stay there you know um can i refresh no going back inside so the folder still stays there however if you go into local state you're going to see that and the virtual drive is not there anymore okay uh great so the next thing that we're going to do is we're actually going to just for fun uh go again and install it because i want to show you that it's going to be installed in exactly exactly the same folder uh come on okay let's yeah it was it was there why didn't you find it i wanted this one yes all right so let's launch all right so as you can see it installed exactly into into the same folder even though it's like technically still still being installed as you can see the hard drive is becoming bigger and bigger and bigger i'm gonna do the same whatever whatever and i'm actually going to close it and i'm going to unregister it again because we don't really need it because we have a we have a backup okay so let me unregister it again and as you can see the the hard drive just went bye-bye okay so let's close this and and actually import it okay so i'm already in the i'm already in the correct uh correct directory okay ctrl l it clears the whole thing if i go to help again we're going to look at the import command which is [Music] there we go import okay so um we need to specify the distribution which is going to be the new name basically then we're going to have the install location which is going to be the name of one of one of these folders it's going to be the same and the file name which is which is our backup we can also specify the version however in my case the default version is already going to be two and so uh i don't need to do anything okay so this is what we're gonna do we're gonna do import and i'm already again i'm already in this in this directory okay so i'm going to call it playground and the directory is also going to be called playground and the file that i'm going to use is going to be ubuntu underscore backup okay that's all i'm pressing enter so if you go over here into playground see it's already imported it just it just copied the virtual hard drive in there okay now if i do if i do this i should see see it over there playground awesome so this is how you create uh how you move distributions around and also how you can create uh multiple versions of them right you basically we can basically just import it again okay so i'm just going to import it i'm going to call it second second i'm going to use exactly the same backup okay so it's just going to go and import it over here right so now i have like i have two of them okay and um l v there we go by the way this list doesn't always uh update you know right away you you need to restart windows terminal uh let me on register um now i want to keep the playground and register second one okay so if i go inside the hard drive is just gone now we can also remove the folder all right so the next thing that we're going to do is i'm actually going to go back to uh to the settings which might still be open in my visual studio code are they no they are not all right so let me press ctrl comma and it opened in my sublime well actually i can i can keep them open and sublime let me actually just just do this all right so um [Music] how do i remove the menu okay in any case uh if you go down over here it actually has a list of of all the distributions that you have and of all the shells that you have so for example you have the powershell you have the cmd exe you have the azure cloud and now i have my work i have my space i have my dev inside you and i just wanted to show you that it doesn't always keep this list uh uh this list up to date so sometimes you need to go over here and you clear it uh maybe actually if i close the windows terminal and i open it again okay so this list uh refreshed maybe this file refreshed as well did it it didn't okay so sometimes you need to go and help it out maybe if i close it and open it again let's see no it's something somehow it didn't it didn't refresh okay uh any k in any case like we we actually deleted this one um there we go like this okay i just wanted to show you that it has like one of the things that it has it has this starting directory which goes into uh which goes into here okay so if we just open it and it doesn't open because [Music] because we don't need these two uh cannot access okay probably because we need to go inside first uh let's go into playground okay let's try this again it cannot access it why not it should be it should be oh it's because because it's like it has like all of these backslashes okay so let's try this okay playground and home home and blab over here okay this is going to be uh this is going to become important um in a couple of um seconds okay now um all right so let's start looking at it so the first thing as as are the um as you can already notice um first of all we've seen like this typical output that you would see like on you know typically on like server installations of ubuntu where you're like connected and it shows you like you know basically shows you what's up shows you some some information you know how many processes are running uh you know what's your ip address and blah blah and um it says that you can disable it by creating this file dot hash login okay but uh for some reason we're we're being logged in as root and in order to fix that which is the first thing that we're going to do to to fix it we're going gonna go to um by the way things like bim and git are already installed so we're gonna go into um so we're gonna do a suit of them even though we're root i'm still gonna do suit of them we're gonna go into slash edc slash wsl.cont okay and we need to make sure that over here we have user and over here we're gonna have default equals vlad okay like this or basically you know basically your user okay so i'm gonna write and quit okay i'm gonna close it i'm gonna close um is it still running that's an interesting question and uh it is still running okay so let's see if we try to just connect it again playground still root okay so it means that we actually need to shut it down like this okay connect it again okay and as you can see we're now in my home folder as as blab the other thing that we're going to do is we're actually going to go back to the settings on my windows terminal we're going to make sure that the first directory that i'm that i'm connected to is going to be my home folder and not the home folder from from windows and by the way this is where the drives are mounted right so if you do m t slash d for example and this is going to be my my d hard drive so let me open up the settings again and let me bring them into this screen okay so i'm just going to go down and i'm going to find playground and uh actually i already have these settings this is this is weird like this is the thing that i was that i was talking about before so this uh id and by the way i actually have no idea how to find out the the id of the of the instance but anyway in the preparation for this video i was creating a virtual machine and you know i was creating a wsl2 instance and i called it playground okay and so because of this it kind of stayed right because it manages them by by name so let me actually try to remove it okay and as you can see it was regenerated for me and so now probably the id changed okay and as you can see the you know the starting directory is not even there so i'm just going to duplicate this line i'm going to bring it down let's not forget the comma because it's json and let's also not forget to change this okay in fact when i was you know um when i started working with wsl2 i duplicated this line and it was a typical copy based mistake and i um and i didn't notice uh that you know i forgot i forgot to change one of these and then what happened was when i was like starting this machine it was also behind the scenes starting this machine as well which is kind of curious all right so let's close this and so what it means now is that if like even if i close it you know if i if i terminate it if i connect it now it is not going to see my you know it's not going to see my setting okay all right because the setting was just a very specific windows terminal setting and by the way like all the windows terminal things that i'm showing it to you i you they're obviously not going to work in a different terminal like alegrity for example however if we go and click over here and we click on playground then it's actually going to work it is going to work and it's going to open it in my home folder which is good enough for us as we will see as we will see a bit later okay let's close this one uh another sort of like annoying thing that we're seeing here is like is this line to run a command as administer administrator uh user root use sudo um i believe that you know in order to get to get rid of it um is actually enough to run one of the pseudo commands so if we do something like um apt update you know it never hurts to actually update your machine okay so this just updates the the cache of the app packages and now we're gonna do come on finish come on there we go so now we're gonna do um hyphen one full upgrade all right there we go probably take um it should probably take a minute because um because it it you know you i never know like how often they um they they package a new version and then put it on the uh to the windows store okay but you know it's wso2 so it's kind of fast and i'm running on an ssd and i have a fast connection so it should actually finish in just a couple of seconds and there we go and also what i prefer to do is this which is auto auto remove all right great so now i believe if we terminate it playground and go inside again then we should not see this line yeah we're not seeing this land okay cool so um one thing that we're going to do is again it's it's specific to windows terminal uh so what we can what we can do is let me actually go out and actually terminate it okay let me actually close this entire terminal and also close this way we actually didn't need it anymore so if i show my desktop icons if i right click at any point i'm going to do new and i'm going to do a shortcut then i can just do you know for the location i'm just going to do a wt for windows terminal and i'm going to do next and it's going to be same type a name for the shortcut i'm going to call it playground playground okay and now if i do a right click over here and go to properties and over here in the target i'm just going to do hyphen p right not d half and p and then i'm going to do playground then what's going to happen is that if i double click this it's going to open the windows terminal and it's going to go and connect straight into the playground vm we're not seeing it over here by the way because as already mentioned in the previous video it always you know the host name is is always uh you know the the windows host name and my windows host name is agilent okay and this is going to be the first thing that um that we're actually going to change after i show you that um as i showed you in the previous video if we go so i'm going to cut it out and i'm going to go into properties and i'm going to go into advanced system settings i'm going to go into environment variables and i'm going to see this path for my for my user i'm going to go into edit and over here i have one of these folders this is my folder with a bunch of shortcuts so if i go in there which is this folder and i just paste this shortcut okay so i just pasted it in there so now because this folder is on the path okay i can at at any point in time i can just do windows r i can just type in playground i press enter and bam it just started which is really really um really really awesome okay so the next thing that we're going to do is we're going to go into my uh bash rc so in my other vms i'm going to call them vms it's just i'm just used to call them mediums so my other ones i'm running zsh and so what you the only thing you can do here is you can basically just change your prompt okay i'm going to show you how to do this with best rc because with dsh you know your prompts are always different and you know you can do it however you want so i'm going to go into uh bash rc and around line 60 you're going to see this if color prompt yes then you know this is going to be your prompt otherwise this is going to be a prompt and inside of it you have this backslash h which is the the hostname okay so all we need to do is we need to go um and we need to go and find this age and over here we just need to go into the insert mode delete these and we can put whatever you want okay so i'm going to put playground okay the same thing over here i'll just go over here and i'm just going to do like this playground like this okay so i'm just gonna do right quit okay get out of there playground and there we go i'm vlad at playground okay so we didn't really change the hostname right it's just a it's just a prompt all right for my next trick i'm going to need my ssh keys and i already prepared them and they're just laying around in my d folder they're zipped okay so the first thing i'm going to do is i'm going to install unzip like that all right and the next thing that i'm going to do is i'm just going to make sure that i'm in the home folder and i am and i'm going to do unzip from slash mount d and i just have this zip laying around in there so i'm just going to unzip it okay so as you can see uh i have the ssh folder in there right now with my keys all right so um what i'm going to do now is i'm just going to go out like this and i'm going to create a def folder and i'm going to cd into okay and so what i'm going to do is i'm going to clone one of my repositories because what i want to show you is that because it's a it's a minimal version of ubuntu we don't have any ssh keys management here okay so checklist final get okay so now i need to unlock my key okay so usually like in a regular mood installation because your key is unlocked if you go and do uh let me actually see d in there okay so if i do like git pull it shouldn't ask me for the key again okay but it does okay and if i do again it's going to keep asking me okay so it doesn't cache my key okay and in order to fix that we just need to install a teeny tiny little tool called keychain keychain like this okay and now i'm gonna go into my uh profile again which is which is in the home folder i'm gonna go to the bottom okay and i'm just gonna enter the following keychain right so please run the keychain with these flags no gui and run it quietly quiet okay then go into my home directory home like this into ssh into id rsa which is my private key okay and then after this please source the following home dot key chain okay then please get out my host name and as a reminder my host name is uh agile nomad and then hyphen sh not dot sh hyphen sh okay so uh [Music] right quit like this so if i exit now if i run it again what's gonna happen is the first thing that is happening is enter the passphrase okay so i'm entering the passphrase like this i'm going into dev i'm going into title's final i'm doing good pull and it's not going to ask me for the key and again it's not going to ask me for the key all right for my next trick we're going to kill two birds with one stone uh one issue that we have is uh you know gui applications they're just not you know they're just not running and uh another issue is the uh clipboard sharing okay now this is a windows terminal right so this is just a just a regular terminal so if i go into them and i open profile okay i just opened like some random file okay so if i just mark some some some code over here and i do ctrl shift c obviously it's going to copy it rather go to notepad and we're going to paste it it works just fine and the same as you know if we do like blah and i'm just going to copy it over here i'm going to go over here i'm going to go into insert mode over here and i'm going to do ctrl shift v it's going to work okay but this is not how i usually work in them and then we usually uh copy and paste in the normal mode okay so uh let me undo all of that stuff so usually in bim you would i don't know go over here and then mark these lines and then you would press y and it would copy it as you can see it says four lines yanked okay and then you would go i don't know to the bottom of the file and you would paste this and as you can see they were pasted okay now the first thing that we we need to know is that uh vim itself needs to be configured as the first step to share the clipboard with with linux okay so for example if i go over here and i yank two or two of these lines which which did it do that why doesn't it show me that two lines were yanked let's let's try with these ones okay yank okay four lines yanked i'm not sure why didn't why didn't show it to me over there in fact let's let's let's grab something else just in case okay so let's um let's grab this if expression okay so i'm gonna do yank okay six line yanked okay so now if i uh exit exit vim and i'm gonna try you know control shift v as you can see it's still pasty blah okay so the first thing that that we need to solve is that and the clipboard is actually not being not been shared with vim in fact what i'm going to show you is i'm going to show you the stuff in neil evan because this is the one that i'm using and i know how to configure it okay so the first thing that we're going to do is we're actually going to go install it and a long time ago i gave up on linux package managers because um you know they are always they always work work differently they did not always have what i need and sometimes you know if they don't have it then somebody else has it and they can add you know a source uh in there but then a couple of years later they stopped maintaining so at some point i just stopped maintaining um you know i sort of created like a poor man's um poor man's package manager okay so if you're going to install.davinci.com you're going to find a bunch of install hyphen scripts okay and you can also uh search them you can either search over here or you can just do install them inside.com for example vim and it should find uh okay maybe maybe it's gonna find with neil okay install neo okay so now i found new of them okay all of my install scripts first of all they're working without any warranty okay but it's always like this you just copy these two lines the first line just downloads the the install script the second the second line just runs it and in this particular case it pretty much just goes to uh just goes to github and um maybe we can actually zoom in it just unpacks it into user local bin i believe okay so uh i just copy pasted these two lines and i'm just gonna go over here and i'm just gonna go and paste it oh that's the thing you know that's the thing i cannot uh i cannot paste it well actually i should be able to paste it with ctrl shift v uh hold on uh maybe i did not copy it okay let's copy and let's go and paste it okay so ta-da and now i should have uh neo-vim and ta-da i have okay great so the first thing that i'm gonna do is i'm actually gonna go and i'm gonna create a directory for the for the config file so if i go if i go into config it doesn't exist really all right so i'm gonna do make directory uh p dot config uh and them like this let's actually go there config and then and i'm going to create a file called init init them okay so the first thing that we need to do is we need to set clipboard equals unnamed plus okay so this is the only line that we need okay and i'm actually going to exit it and another thing that we need is we need to install a tool called xclip all right next clip okay so this this should be everything we need to in order to be able to to share stuff uh between um between uh vim and linux however it's not gonna be enough to be to share the clipboard between uh linux and windows okay so let me open end them whatever blah okay so i'm gonna type something and well actually let's type something like hello world okay so i'm gonna exit and i'm gonna save the file okay so let's yank the current line and i should be able now to uh close them close them and i should be able to paste it and it did not it did not do this i'm not sure why um it should have been should have been able to do this uh maybe maybe even for this we're gonna need another tool maybe we didn't actually yank it like i have i have hold on why why okay if i do p okay so it's so it's there so if i'm going to quit and i don't care about the changes ctrl shift v now for some reason it still it still doesn't work okay hold on uh if we do uh check check health check health okay then it should tell me that um clipboard warning tool font um oh yeah okay so the thing is that if we're going to help clipboard help clipboard okay then uh we're going to see somewhere that it actually only uses x-clip if if the display property is set okay or um or if it's actually in uh you know if the t-max variable says so because i'm usually using t-mugs um this was actually enough okay in any case uh let's actually uh get out of here and get out of here as well and get out of here as well all right so uh what we're gonna do is we're gonna uh finish the entire installation and then it's just gonna work a workout because uh for this for the next uh step we're actually going to need to set uh this display property okay so um as already mentioned in the previous video there are two ways to have uh gui applications uh one is to basically install like the entire ui inside of uh something like ubuntu for example and then connect to it was uh uh you know was a remote connection tool like a team viewer or something or something something similar another another uh way is to install an x or which i already have it's running over here there are a couple of them this one is the x ming server you just download it and you just open it come on four three two one uh in the meantime i'm actually going to close this one all right yes exit okay so i'm just gonna run it and i'm just gonna say next next um all the defaults are fine you know all the defaults are fine uh you you for sure need this x launch x launch wizard okay thanks me yes next next yes create all of that stuff install install install la la la uh launch x-men okay so if you're gonna launch it uh okay in my particular case it just launched it this is not what i was expecting i believe if you don't have it installed what is going to happen is that it is going to go to uh program files and somewhere at the bottom you're going to have xming and it should have run the launch exe okay so this is the one that that you see by default and uh you can make your decisions over here just make sure to remember the display number okay i like what i recommend is just leaving it over here as multiple windows display number is zero uh next and start no client next clipboard and very important to enable either no access control or you would need to open the windows firewall so that um you know the linux clients can connect to this server so i'm not going to touch the firewall i'm just going to click next over here and very important over here you can save the configuration so if we save the configuration and it's going to be called config.x launch i'm going to save it onto my desktop okay i'm just going to save it okay and now i can do finish and it's going to start over here i'm actually going to close it because i want to show you that i want to show you that uh okay so these are just the shortcuts okay this configuration is actually an executable file so you can just double click it and it's just going to start over here so what i do is i'm actually going to cut it out and i'm going to open um i'm going to press windows r i'm going to type in shell colon startup and this is the the startup directory and i'm just going to paste it over here so as you can see like every time you're going to launch windows it's just going to launch this um this x server for you okay so uh let me actually exit it because i believe like sometimes it's important for the server to you know for the clients to connect like uh later uh but we actually didn't configure the clients yet so let's actually go in and um configure the clients okay so what we're gonna do is we're gonna go into profile and now that i have nvm installed i'm gonna do like this profile and let me do a full screen okay so i'm going to go to the bottom and what i need to do is i need to export um i need to export this um display variable that we have seen in the health check uh for uh for them okay so i'm going to do export display and the value is going to be a little bit complicated so we're going to ask to evaluate an expression okay and then once it evaluates after this we're going to do colon zero so the column zero is a display the one that we we have seen during the during the launch in fact maybe we can actually do this again real quick so if i go if i go to the bottom x-man and launch okay is this zero over here and also it's part of the configuration so if i go over here and i open this with i don't know something like sublime text and it opened in my other on my other screen okay so as you can see it's this display display zero okay uh right so let me close that close that okay another thing that we need is we're gonna export lip gl always indirect equals one and i'm gonna have a link down in the description which explains exactly what this flag is for okay now we're almost done the only thing that we need to put over here is the ip of the of the server and the issue is that a virtual network interface is created for for your virtual machines and again i'm going to keep calling the virtual machines and the ip changes every time so if i go to my network then i'm going to go over here and i'm going to see this one ve7 and wsl so if i go into properties and i'm going to go into ipv4 i'm going to go into properties it is going to be this ip that we actually need in fact i'm going to leave this thing over here so that we can compare it later now luckily for wsl if i actually um let's do what is it ctrl z yeah so i i sent it to to background yes control z sends it to background all right so um there's a file there's a file um edc resolve cont okay and in this file this ip will be written okay so all we need to do is we need to to have a little bit of linux magic to go into this file and read out this ip and this is the magic okay so it goes in there and just and just copies the copies dip okay let me actually create a bit more space that you see okay so all we need to do is we need uh to go over here go into the insert mode paste it over here okay so it's going to take the ip put it over here and then it's going to do the the column column zero okay so right quick all right quit uh let's actually exit just in case uh let's go close these guys close close close let's look so close this one okay so let's launch the windows terminal let's actually shut everything down okay like this exit and we're gonna do playground and so the first thing that we should see is after i enter my key is that this display variable display variable is shows me now the ip which was taken from edc resolve dot com okay it is exactly sap and the display zero okay which means that if we had a gui application it would send stuff to um to do went to the x x main uh server over here and it would display stuff and the same thing for the um uh for the clipboard in fact if we go into uh you know vm was blonde and i'm going to do this check health again it should now say that the clipboard is configured correctly okay because it says you know clipboard tool found x clip and it was only looking for it because the display variable is set okay so now let's get out of here okay so let's for example um let's just um mark uh you know just this word and i'm gonna yank it okay so now i yanked it so if i paste it it's gonna be world war world and now if i go into notepad if gods are going to help me it should paste it world there we go it worked and the same the same as we're going back okay so if i'm going to say i'm going to say vlad over here i'm going to copy it and over here notice that i'm i'm in the normal mode okay i'm actually going to go into insert create a couple of lines okay i just press p and it's going to insert black okay so the clipboard sharing is not working correctly so the other thing that i'm just going to demonstrate is that the gui apps are working normally as well okay so let's close that let's go back to my install page and we're just going to do install um okay let's go back like this and let's just do those sublime okay so i have install sublime text if you don't trust my scripts you can always just uh click inside it real quick and see what it does in this particular case it just adds the key you know does the app install and stuff all right let's go back over here go into full screen i'm going to paste press enter my password and we're just going to wait a couple of seconds and then sublime is going to be installed there we go so if i just do sub dot for example the x-men server should catch it and as you can see it just started sublime in my oh that's the windows thing okay so i just started sublime in my in my home folder all right let's close it again and uh yeah so we're pretty much actually uh done uh you know everything like um all of these like copy paste you know like all of these like long commands you can always take them from from here so this is like this is the stuff that we just did for example okay uh i still have a couple of uh small things to show you uh one of them is the reminder that there's no systemd support so if we install something like uh docker docker okay uh like again like even docker you know there was an older version in the um in the default repositories so i'm just gonna paste this it's gonna install docker for me all right so my script says docker is now on the path and i was added to the docker group so that i can run docker without sudo however the changes to the group are not yet applied so i need to exact s u l vlog enter my password and now i should be there okay so now i should be able to do docker run hello world okay and it's just going to say hey can i connect to the docker demon right because there's no systemd even if i if i go out process exit was one two five really what come on what is happening to you whatever let's just close it that's the beauty of virtual machines let's see what's up it's running let's just shut everything down we don't care exit go in there again all right enter my key all right docker run hello world okay there's no systemd support so we need to do sudo service docker start okay my password and now we should be able to run hello world unable to find image so it's going to download it blah blah blah it's going to do the whole docker thing and there we go it worked and if we do it again the image is already downloaded docker ps all of the things they are just working great by the way if you're kind of lazy to do this then you can also work around this by not having a password and then just putting it you know putting it into your dot profile so that we just started but i'm not that lazy okay uh all right so the next thing i'm going to show you is um i'm actually going to go and i'm going to go over here and i'm going to go into no not here business ws playground okay so the the drive is now 2.5 gigs basically so what i'm going to do is i'm going to show you how to shrink it if it doesn't um doesn't give you the space back okay so i'm going to go and set again okay let's actually minimize it like this so what i'm going to do is i'm just going to copy into my home folder from m t d business step inside you videos i don't know some random number and i'm gonna um i'm gonna see [Music] um this should be a large file like 220 zero mlv okay so uh basically i'm i'm copying i'm copying some large file inside of this uh inside of this virtual drive so in this particular one uh should be um i don't know like 10 gigs like usually usually like an hour of recording um is like around 10 gigs for me and so it's gonna take a couple of seconds to to copy it over it's actually in the meantime go and check it out so this is the um 185 which is 1.85 it is this one yeah so as already mentioned it's around you know around 10 gigs so even though i have an ssd and by the way this is um this is a sort of like a reminder right so if you know wsl 2 you know the io and wsl 2 is actually faster unless you're actually touching the windows system right so i have an ssd and it's copying over this like 10 gigs files and i've already been talking for what like a minute or so and it's still copying okay so uh if you're frequently using io you know in in such a case in such a scenario that you have to hop back and forth all the time then you might as well um switch back to wsl1 okay which is very easy to do by the way i actually forgot to mention it uh so one of the commands over here uh one of the commands over here is the set version command right so you just set the version uh two to one for example you know uh for example you would do like wsl wsl you know set version and you would say playground and you would just say one and it would convert it to wso1 and all it would do behind the scenes it would actually just you know just export it and then import it back right because it needs to convert you know so in this particular case if you're going from wso2 to wsl1 it would just convert the virtual hard drive into into the windows file system right and then the i o would be faster in this particular case it probably will be instantaneous because it's on the same hard drive so it would just change the path in any case it copied it over okay so it's um over here now as you can see uh do you this usage age 220 there we go so it's the 11 gigs over here so if we actually close it and then we're going to see that the hard drive now is 13 gigs okay 13 gigs so if i go in there now and i'm actually going to remove this file okay just remove it as you can see it's not it's not there anymore however the hard drive is still large right so even even if we go and and close it right so if we do a shutdown okay it's not just going to magically give up the space right as i already mentioned in the previous video you know i can refresh and whatever it's not going to give you give you this space okay it's very typical for databases very typical for you know virtualization solutions so all you need to do for this is you need to open the powershell and you need to make sure to run it as administrator you can also right click over here run it as administrator okay so uh the font is kind of small properties uh let's do like 24. all right great so what i'm going to do is i'm going to go into this directory so i'm going to d and i'm going to do cd business ws cells and playground actually as well okay so uh what i'm going to do is i need to make sure that everything is shut down okay and now what i'm going to do is i'm going to do optimize i should have okay i should i have tab completion but it's useless yeah so this is the one we need optimize vhd and i'm going to do path okay and i'm just going to say that in this current directory there is ext4.bhdx i just press tab it actually auto-completed it and i'm going to do mode and i'm going to do full okay so now i'm going to press enter compact in virtual disk it shouldn't be that long actually and there we go it just went back to went to the original two gigs amazing okay so now we can run it again it still works i actually read that a couple of people had uh had some issues with it i believe the issues were related to to docker okay so yeah there we there we are let's close it again all right now i actually wasn't planning on doing this but let's actually do this as well so if i go to playground again and i'm going to go into into this directory which is a you know this is a scholar project so as a reminder the the path is shared well not shared it's merged with windows and so if i do uh you know code dot right so i'm starting visual studio code in this directory it will actually uh run you know visual city code and the first thing that it notices is that we don't have the server um the server version of visual city code inside of this wsl so let me actually minimize it okay so behind the scenes what it did was installing vs code server for x64 downloading blah blah and picking blah blah so every time i update um visual city code on windows it would actually go and um keep installing something okay so what's happening over here is that now it's connected to wsl playground and as already mentioned in the previous video it's the the first time that you do this then it will actually offer you to install the um to install the exa the the uh wsl remote extension okay so um now that it is installed i want to show you that the extensions that you have installed inside of your uh visual studio code for for windows which are over here they're not automatically installed in the in the in your wsl uh installation right so they're and by the way they would be installed like per uh per vm okay so in this particular case that's inside of the playground and so nothing in there now since this is a scala project i need to know i need to go to metals over here and as you can see there's actually a button you know that says you know do you want to install it in the wsl playground and i'm like yeah sure why not so i'm clicking it and now it's installing um i actually can go into full screen now okay reload required let's reload mm-hmm all right so now it says fail download metals make sure that um your connection to java home is correct now everything that i'm showing now is sort of related only to scala into java so in this particular case if i go into metals i just want to show you that if you go into extensions okay and you're going to see that now you have settings for your user you also have a settings for workspace the same as you had before but you also have specific settings for for this remote wsl playground okay so what happens is that in my user settings i actually specified that this is where my my my java home is okay so if i actually remove it for for everything okay reset setting okay reload window um everything that is happening from now on uh is it's just just relevant for scholar developers okay but now it actually offers me to install um jk 8 or 11 and i'm actually gonna go and i'm gonna install eight now it says command fail permission denied i'm actually not sure why this is happening it actually worked before so let's try this again there we go it looks it looks better now okay so it should take a couple of seconds downloading metals so now it actually detected my jvm which is cool i can actually close the settings go into some main file like this in any case all i wanted to show you is that you know vs code understands that everything that is happening now is happening inside of the inside of the vm uh you know if we open the the terminal or something then we're going to see that we're inside of the vm okay so now that metals is installed it will probably tell me that we should import the build there we go oh i opened the wrong directory actually i actually wanted to open i actually wanted to open just this there we go all right so this particular repository actually contained two different projects let's go into main save it terminal and metal should wake up in just a second and tell me that it wants to import the project import build all right now i actually don't really care about about the remainder of the installation because now it's going to start installing spt and all of this stuff and you know import the project i wouldn't really uh care about this anymore my laptop started thermal throttling again sorry for that so i had to kill the vs code instance but in the preparation for this video it actually worked out just fine so i'm sure that this kind of worked out just fine uh in any case i i finished showing you everything that i wanted to show you and i hope that um you know that um if i've you know if i've forgotten some gotchas then i'm gonna add them to uh to this file over here you know i'm gonna make sure to to keep it a little bit up to date and i hope that this video saved you some time and also some pain and also congratulations you're now the local wsl expert and uh yeah as always it's been vlad that's higher.com don't forget to like this video if you did subscribe if you want to improve the developer inside you and if you learned something today consider support me on github sponsors or patreon whatever you prefer and just watch my videos weeks and sometimes even months before everyone else but most importantly take care
Info
Channel: DevInsideYou
Views: 4,439
Rating: undefined out of 5
Keywords: scala, software, development, programming, tutorial, dev, tutorials, code, learn, education, knowledge, diy, dev inside you
Id: BOSDJiaU-uI
Channel Id: undefined
Length: 58min 44sec (3524 seconds)
Published: Sat Nov 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.