WSL2, Visual Studio Code, Windows 10, Ubuntu/Linux + more - Computer Stuff They Didn't Teach You #19

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey friends i'm scott hanselman i've noticed a lot of people a little bit confused about using their windows machines when they also have wsl the windows subsystem for linux on their machines as well as the different choices that are available with the windows terminal and all the different prompts they can have so let's spend a little time talking about that here's my windows machine all right i'm going to fire up the windows terminal now let's take a look i've got the windows terminal on the windows terminal preview two different choices like the windows terminal it's quite easy it's just available in the store i'm just going to go and confirm when i look at it that it's windows terminal at the time of this recording 1.6 you get the newer windows terminal 1.7 which is currently in preview i'm going to bring that up or if you're looking at this video in the future sometime you'll be getting probably 1.7 or later that's going to give you some real benefits like nice settings gui this this interface here is is new and means you that you don't have to go and mess around with the json files anymore all right now we've talked about this a little bit before but i just want to remind you all that you can totally customize this these are called profiles the windows terminal it's not a shell it's an a terminal or a console application that lets you use lots of different shells and for most people when you think about the command line on a mac or on windows you just think about like the dos prompt maybe you'll go down here and you'll say cmd the command prompt it's not really dos you go like this and you type things like dir or maybe you're used to typing powershell you bring up things like this with the windows terminal you get a better experience and you can control what you bring up here which is really nice okay now i've gone also and customized mine you can see here you can change your props whatever colors whatever look and feel you want this particular one here is called oh my posh oh my posh oh my gosh three in fact you can learn more at ohmyposh.dev and all it is is a theming engine for shells it's just a way to make yourselves look cool what's nice about it is that it works on anything if i go down here to installation i can do it on mac on unix on windows do it within powershell it's pretty flexible so this has made a nice little deal here that shows me the current version i'm running of dot net it shows me a little heartbeat that indicates if there was an error or not if i type something that would cause an error then the little heart and turn red to tell me that the last terminal was an error and i can control these these segments the segment could show my battery or anything like that this is running within the context of powershell but i could also run ubuntu or something like that now in order to get ubuntu running i would have come here and i would have typed in windows features windows features oops it only does this when someone's looking isn't that the way i type really fast but since we're on youtube we don't type so fast and under turning the windows features on and off very bottom here is the windows subsystem for linux right here if you turn on these two things you are not required to turn on hyper-v just turn on the windows subsystem for linux and then i can go over to the microsoft store type in linux pick any one of a number of flavors of linux that are lovely and then those will automatically show up here like ubuntu now i'm going to hold down the alt key so i've got my left thumb i'm going to hold down alt while i am clicking with the mouse here so i'm going to go alt click and in doing that i'm going to actually split screen i'm going to set up a split pane now i've got the windows terminal with ubuntu on the right and i'll actually show you this because i went to the work of making a nice little graphic right here there's ubuntu i've got powershell here and if i wanted to i could also hold down alt again and pick something like the command prompt and have the windows command line there and i've just customized that right so if i go here and say settings and then look at my profiles here's the command prompt profile and you can see that i put in an icon and if you go under appearance got my colors and a custom background path basically custom image so the shell is not the terminal so this is a good reminder i've got other videos about this i'm going to hit ctrl w to close that that's a hotkey that i've set up you can go here to settings okay look at all the different actions that you've set up and you see here i've got control w is closing a pane control w is also the same thing as closing a tab which is interesting to point out okay so on the left hand side we've got powershell i'm going to go to the d drive go to the github folder and i've got all my code there and then over here on this side if i wanted to go to the d drive remember i'm in linux here on the right hand side there's no d drive but there is a mount point under mnt and in that mount point are all of my windows drives now i could go in there and now i am in linux in the real ubuntu but i'm talking to the d drive on my windows machine that's going to cost me you're not going to get full speed linux if you're going across a network drive a mount point even though it's local a bit of a network hop so instead what i do is i share my code with git if i go over here to oops those bells are annoying i go over here i've got for example the hanselman website and if i type pwd you'll notice that it's on the home directory on scott in the hanselman folder if i go over here in windows go to the hanselman folder we've got d so you're treating these as two different systems so i'm going to go and say git pull in windows and get pull in linux make sure it looks like windows was already up to date it looks like i did have a update over in linux that's an easier and better way to get full speed so right now if you look at the file system in ubuntu here i think what is it f udf util dfu tool i always forget that maybe it's just df there you go those are different drives and where they're mounted all right so i use net but the example i'm showing here imagine using python or go or whatever makes you happy javascript node i'm going to type net dash dash version i'm going to type witch.net and you'll see that there's in userbin.net because that's in the linux world if i go over here and i type where dotnet you'll see it's in c program files if i go and type net dash dash version i've got one version over here and i've got another version there it's because you've got two machines that you need to manage one of them is a windows machine on your left one of them is a ubuntu machine on your right still the same computer but it's two different operating systems so they need to be kept up to date and you need to think about your prompts your fonts your path and things like that so i've installed.net in each but i am in the working directory hanselman core which is for the home page of my website if i went over to my browser here if i went over to edge my browser of choice this is the new edge sucks way less than the old edge i hit hanselman.com you can see that there's the website okay that's my my website and this is the live production website running in linux in azure i can go over here and i can say dot net run all right i'm going to go and compile that code and it's going to fire up on localhost 5000. you'll notice that when i hover over the links in the terminal those automatically are clickable which is a nice feature here when i click on that it's actually going to launch localhost 5000 get a little protocol error because i'm actually supposed to be on 5001 for ssl and there's the local version of my website and you can see it's running here and if i hit refresh see the logs happening right there i close that i'm gonna hit ctrl c and now i'm no longer running that in windows switching over to the ubuntu side on the left hand side i'm going to type net run and do the same thing because dot net just like python and node and things like that is cross platform so now i'm running again we're going to hit localhost 5001 and see now that this is running on the ubuntu side i could even if i wanted to be tricky come back over here holding down alt with my left hand and clicking with my right split screen you could use screen or tmux so don't be sad now i've got a split screen ubuntu and ubuntu i type h top make that full screen you can see the dot net run right there then as i close it you see it disappear run it again h top on the right pops up now there it is i can go and do that now here's where things get interesting i'm going to go ahead and close this now i'm running only ubuntu what we're going to do i'm going to type where i think it's actually which pardon me on ubuntu and you can see that there is a link to the windows code visual studio code editor but we're in ubuntu well you can run windows applications from ubuntu because windows is the operating system that we're running outside here linux on windows will give it a chance basically so i'm going to go and type explorer.exe hit dot which is the current folder it then pops up explorer and somehow i'm looking at my linux file system how is that let's move this out of the way i take the splitter bar here so we can see the full url i'll click there and we'll take a look it's slash wsl the windows subsystem for linux is showing up as a network drive in fact any linux that you're currently running will show up there see how to see how ubuntu is there let's go and run another one so let's make a little bit of room so you can see both of them side by side we'll go over here and we'll run kali linux in a split screen and then maybe i'll run ubuntu 20 in another split screen let me come over here to linux let's come over here to explorer rather hit refresh now all of those linuxes are running and they're available and i can get to their drives so that means that i can access these things from windows or from linux allows me to very much have an integration that you can't have with virtual machines just not that fast if you do with a virtual machine so what i'm going to do is i'm going to say dot code.not explorer dot but code dot which we know is a windows application look at this i'm just going to pause this updating visual studio code server actually installing a server inside of linux now look it's gone and it's running this it's running visual studio code look in the lower left hand corner here it says ubuntu 1804 in the lower left corner this is telling you that it's talking to a remote machine not really remote okay it's installed a server here in the home directory called vs code server okay and now check this out go ahead and have our visual studio code this is a windows application it's not a linux application but it is talking to a server that's over here let's look at this let's maybe hit control in the tilde button you'll see that i've got a prompt that pops up and what is that prompt that is a linux prompt i type lsb release dash a and i can see that's in fact my same ubuntu okay that's interesting let's go and look at this if i say file open file i didn't get the windows dialog box for opening up things i'm on the linux file system i've got this really interesting application here in the form of visual studio code that is living in the windows world it is a windows app it shows up in my ask manager but it is talking to the other half of it it's now it's basically become a client server application so i could go then and open up files for example my programs files or maybe one of my html pages here if i make a change to that that is actually happening on the linux file system this is pretty cool because this means that i could now potentially debug my application so i could go into startup put a breakpoint hit the debug button hit play look at this here it's actually launching the debugger and now i'm in a break point i'm in a windows app and i'm doing a break point there and there's the dll the dynamic link library councilman.com or you can see all of the different.net things and again the same exact experience works on node and python i'm just showing you dotnet because that's how i do things this is visual studio code all right now here's another way to look at it remember that i've got that code over on d github on my windows partition for example my podcast website we could go and we could load that up into visual studio not visual studio code but visual studio for windows visual studio proper i'm going to load it off of the windows drive not off of the linux partition this is a visual studio you may be familiar with or may have used in the past kind of the microsoft word of microsoft office of developer tools okay with this it now supports the windows subsystem for linux which is cool you can get this extension here and take a look what happens up here look at my choices for things i can run in internet information server or iis express kestrel which is the default windows.net web server wsl2 or the snapshot debugger so from here i've got my pages i've got all that nice editing features that you expect to get in visual studio i'm going to hit play on my wsl2 it's going to go and fire that up you can prove to yourself that it's in linux because you see those paths dash user dash share same experience that i would expect as if it were running on windows but it's running on linux which is great then i've got my application again running on localhost 5001 all running inside of my default windows subsystem for linux environment which is pretty cool what this means my friends is that the lines about where your operating system is and where your file system is may feel like they've changed but fundamentally you still need to keep track is it on my windows partition is it on my linux partition is it on my d drive or my c drive once you are able to get that in your head and move seamlessly between those things i can be a linux developer on windows eventually i guess maybe i could be a windows developer on linux it's not quite as easy but what's nice about the windows subsystem for linux is it's turning your machine whether it's got uh windows 10 pro or windows 10 home this works in home as well if you're an education student you install this you get visual studio community which is free you get visual studio code which is free you install the windows subsystem for linux as well as ubuntu which is free python go ruby node go nuts have a blast i wanted to explain that to some folks please let me know in the comments if you find this and videos like it helpful i think that this qualifies as computer stuff that they didn't teach in school and maybe in the next video we can talk a little bit about what would happen if that work that was occurring on my computer was happening in the cloud but i still use my visual studio that might be interesting as well thank you so much and i hope you have a lovely day
Info
Channel: Scott Hanselman
Views: 53,455
Rating: 4.9771972 out of 5
Keywords:
Id: Owrk9UxnMdI
Channel Id: undefined
Length: 17min 32sec (1052 seconds)
Published: Fri Mar 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.