Windows Terminal and WSL 2 tips

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- This is one of multiple videos in my WSL version two series. In this video, I'm gonna show you some tips and tricks. I'm gonna show you, as an example, how to use the Microsoft Windows Terminal. You can open up multiple shells to various Linux operating systems running within WSL version two. I'll also show you some additional tips and tricks in this video. So as an example, how to open Linux files from within Windows, or how to access Windows files from within Linux. Use the menu below this video if you want to jump to a specific topic. So if you're not interested in the Windows Terminal, but you just want to see how to open Linux files within Windows, then use the menu to jump to that topic. Okay, so let's get started. (upbeat dance music) ♪ Yeah, let's go ♪ (upbeat dance music continues) - Microsoft have released a Windows Terminal that makes it a lot easier to work with multiple consoles. So I'm gonna go to the Microsoft store, and I'm gonna search for the Windows Terminal. And here it is, so I'm gonna click on that, and I'm gonna click get, and then I'm gonna click install, to install the Windows Terminal on my computer. It's not a very big installation. You can see it's about six meg. So quite a small installation. And I'm gonna click launch to launch the Windows Terminal. What I've got here is a Windows PowerShell. So if I type wsl-l-v, as an example, I can see that I've got an Ubuntu 20.04 virtual machine running. I can see that the Docker Desktop is running. I can see that 18.04 is stopped, as an example, and Ubuntu has stopped. But notice here, I can click on this little down arrow, and I can open a command prompt. This is the classic command prompt that's been around for many, many years. So as an example, IP config shows me the IP address of my computer. So I've got PowerShell running here, I've got a command prompt running here, but what I can now do is start an Ubuntu 20.04 prompt. So, lsb_release -a shows me that I've got Ubuntu 20.04 in this tab. Drop this down, let's start an 18.04 tab. So, lsb_release -a. I've got PowerShell. I've got a command prompt. I've got an Ubuntu virtual machine, in this case, 20.04, running, and I've got 18.04 running. And what I could do now, as an example, is go into my Docker WSL Integration, and I could enable Docker on various virtual machines, including the 18.04 virtual machine. Click apply and restart, to apply those changes. Go back into my Windows Terminal. In my 18.04 virtual machine, I could type, docker run hello-world. I'm told, "Hello from Docker!" Everything seems to be working right. What I can do now is use this command to run an Ubuntu shell. So, lsb_release -a. And that command doesn't work. So let's install this app update to update my references. What I'm doing now is running, hopefully, a 20.04 Ubuntu within 18.04. So I'll install that software quickly. Clear the screen. So, lsb_release -a. Notice I'm running Ubuntu 20.04 within Docker. When I type exit, and use that command again, notice I'm running Ubuntu 18.04. So in this example, I'm running Ubuntu 20.04 in a Docker container, within an 18.04 virtual machine, which is running within Windows. This is fantastic. I can even open an Azure Cloud Shell here, and log into Azure, log into my various virtual machines running within WSL version two, open up a command prompt, open up PowerShell, et cetera. This is a fantastic development from Microsoft. You can run a whole bunch of terminals, but you can also change the settings. So, if you click on the little down arrow and go to settings, you can change the fonts, you can change a whole bunch of options within Windows Terminal. If you're interested, I'll create a separate video on Windows Terminal. Let me know if you're interested in me doing that. I'll show you how to change a lot of the schema settings and a lot of the options here. But notice you can have different profiles. One for Windows PowerShell, as an example, one for cmd, or the command prompt. One for the different virtual machines that we're running within WSL version two, et cetera. So Windows Terminal is fantastic, great application. But what I want to show you now are some tips and tricks with regards to WSL version two. So this is not a Windows Terminal option. This is just part of WSL version two. So one of the options, and let me go back to home, in this 20.04 LTS virtual machine, is I can access files in Windows from within Linux. So at the moment, pwd once again shows me that I'm in my home directory, but if I go cd root, notice I'm in the root directory. If I go to mnt, ls, I can see the C drive. This is the C drive on my Windows computer. So as an example, if I go to C drive, there are the files on my C drive in Windows. So, back in my Ubuntu shell, I'll go, cd c, and type ls, and what you'll notice is I have these files listed. Those are the files on my C drive. I'll use sudo here so that I can use root privileges. So, sudo ls. Put my password in. Now, after I've put in my password, notice I can see all the directories on my C drive. So those are the directories on my C drive. And I could also do something like, find grep, and let's just grep for temp as an example. And notice I'm able to use Linux commands on Windows. So I'll just stop that for a second. I'm getting permission denied, 'cause I need to use sudo. And let's simply search for devlist.txt. So, devlist.txt, to make it simpler. And, as you can see, it's trying to find the files, but it has found the one file here. So scrolling up, notice it did find devlist.txt in the root directory. Now in the same way that you can use Linux to look at the C drive, or other drives on a Windows computer, you can use Explorer to explore the Linux directory. So I'll type explorer ., and I need to type exe . to run the Windows application. And what it's done now is opened up Windows Explorer, and I'm looking at the WSL hard drive for Ubuntu 20.04. And what I can see here are the files on my Linux virtual machine. So, ls, as an example, shows me those two files, xe.py and xe2.py. And I can see something similar here in Explorer. And what I could do, as an example, is open these files in Visual Studio Code, as an example. So I've opened xe.py in Visual Studio Code. What I'll do is cat that file here, so that you can see what's in the file. Notice there are two print statements at the end. So what I'll do is delete the extra print statement, and go file, save, to save the file. And back in Linux, if I read that file, notice the second print statement has been removed. I could say something here like, print hello from Windows, and go file, save, to save the file. And if I cat that again, in Linux, notice, there's the changed file. So, basically, Explorer allows me to explore files on the Linux subsystem using a familiar Windows application. What you can also do is use VS Code to open files directly. So I can say, code.exe xe.py, to open that file. In this case, it's actually just code. So, code, and I'm gonna open xe.py. And what that does is start VS Code in Windows, and it opens that file directly from within Windows. So I'm opening a file on the Linux subsystem from within Windows. And I did that directly, or you could just use Explorer to do that. So you might prefer using Explorer to view the Linux virtual machine hard drive. So as you can see, there's very tight integration between Linux and Windows, using the Windows subsystem for Linux, so WSL version two. Fantastic options available now, if you use Windows as your primary operating system, to develop on Linux, use Linux commands, learn Linux, et cetera. The Windows Terminal is also a fantastic application. I'm really glad to see how Microsoft have changed their ways and are using a lot of Linux technologies as part of Windows. Okay, so, very long video, but hopefully you've learned something. I'm David Bombal, and I want to wish you all the very best. (upbeat dance music) ♪ Yeah, let's go ♪ (upbeat dance music continues)
Info
Channel: David Bombal
Views: 68,834
Rating: undefined out of 5
Keywords: wsl 2, wsl, windows subsystem for linux, windows terminal, linux, wsl2, ubuntu, windows 10, windows, microsoft, terminal, vscode, command line, ubuntu 20.04, linux on windows, how to install wsl 2, windows subsystem for linux 2, wsl1, microsoft windows, wsl 1, ubuntu on windows, linux subsystem, linux kernel, windows bash, windows update, tutorial, windows 10 wsl 2, #wsl2, windows subsystem, ubuntu linux, how to install wsl2, windows 10 linux, subsystem for linux, wsl 2 windows 10
Id: GFgJgGV4d28
Channel Id: undefined
Length: 11min 3sec (663 seconds)
Published: Thu Jun 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.