HomeНаука и техникаRelated VideosMore From: Scott Hanselman

Editing code and files on Windows Subsystem for Linux on Windows 10

771 ratings | 40568 views
Editing your code and files on Windows Subsystem for Linux on Windows 10 - As well as setting up Ruby on Rails, Node, and C++

Html code for embedding videos on your blog
Text Comments (91)
Bryan Smith (3 days ago)
It is sort of silly in way, but it is fun.
Nitely (13 days ago)
Thanks man! U saved my ass!
Water Cat (18 days ago)
Haw cen run linux program or game for widows 10 im developer and maid game with widows linux and mack
Sushant Bhargav (1 month ago)
Nice , I installed deb last week, gonna try docker on this bad boy. Also Fuck coc linux
Flurt (1 month ago)
sounds like docker.
Kevin Wad (1 month ago)
6:13 open editor from terminal
Noor Jafri (2 months ago)
Hey Scott, just bumped into your video, I tried setting up pycharm with WSL and its so hell lotta difficult :p with all virtualenv thingy. I want to work for linux machine and I went with WSL - Pycharm(for debugging stuff) and it seems really pain in the ass to setup everything. Whats your experience with that.?
Alex Walpole (2 months ago)
very helpful! thank you!
shashank sj (2 months ago)
can u share your .bashrc file
Susan Amber Bruce (3 months ago)
Could you explain how to connect to a Linux system from Bash on Windows using ssh, please
Chiramisu (3 months ago)
GRRR... I followed this: https://code.visualstudio.com/docs/setup/linux ... and even manually installed missing dependencies: https://github.com/Microsoft/vscode/issues/13089 ... but I still get nothing when I type "code ." in WSL from my working directory. :(
Lachlan (3 months ago)
3:12 Thank you so much for this.
Justin Burkard (4 months ago)
Did you need to do anything special within WSL to use the 'code' command? Or did that just work because it's already on your Windows system PATH?
Nicholas Willcox (4 days ago)
I have no idea how everyone does that - I've tried setting up Ruby on Rails on Windows 3 times now and can't do anything like that anyone else can for some reason. You ever find the solution?
Mariam Ahmed (4 months ago)
why can't i do it on the HDD drive?
Tom Branson (4 months ago)
Great video! Thumbs up! It has answered most of my questions about the linux system on windows I program in Ruby, Python and this is awesome, as it seems that some libraries for these languages are better suited on Linux. Question, though, do I need to install a separate version of Ruby or Python? or is it just using what I have installed and through the ENV Path? I would like to program in C with the POSIX library using either Visual Studio Code or Visual Studio... I am a little lost as to how I direct towards a compiler when I would be on the Linux subsystem with the Windows C: drive directory using an IDE? I'd like to get access to the socket, fork, and thread libraries... any advice? Thanks
Christopher Ivan (5 months ago)
Useful video, but the author seems like someone I would hate to have to work with.
Georges videos Paris (5 months ago)
Doesn't seem to be able to do this on Windows 10 anymore wasn't able to find Windows Sub System for linux under Windows features even though l enabled developers mode ???
Lan Lay (1 month ago)
You can install it through Windows Store now, search Linux in Store. Good Luck.
TelFiRE (6 months ago)
Had this working just fine for a while, put a symbolic link in /var/www/html/ so that I could access a site I was building on my C drive. But then Apache2 arbitrarily stopped wanting to serve me anything. Even new stuff I create now, it refuses to serve: "You don't have permission to access /rafflr on this server." And the error log says: "[core:error] [pid 53] [client ::1:51631] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html/rafflr" Any advice would be greatly appreciated.
Reza Sadr (7 months ago)
How can I make vscode use the Linux git?
Alex Leibowitz (8 months ago)
Oh damn! I wish I'd known this before I started setting up my file system on the Linux partition. Visual Code Studio does seem to be able to open and edit the Linux files without problems (so long as you don't try to drag stuff into the folder or create any files from Windows) -- but it definitely is a little janky, not very fun.
Joseph Kueche (8 months ago)
ca ne marche pas cher moi... lorsqu'on me dit d'appuyer sur une touche ça disparaît
3D Art Basics (9 months ago)
Nice video, thank you. How did you set up such color scheme for your terminal?
Suntorytime (9 months ago)
Thanks @Scott, you just helped resolve one of my gripes moving from Mac back to Windows for development
Marat Ablayev (9 months ago)
just WOW!
twfljeb (11 months ago)
All of this seems so pointless when you can just boot into a native Linux environment and not run Windows at ALL. Why did they even bother? Why not just make Windows run well? Linux already runs well.
theupandup (1 month ago)
If your job wants you to develop in Windows, you should develop in Windows. Being consistent with your team is important.
Attila K (1 month ago)
Let's say you are in a corporate environment where you get Windows. Period. Without WSL you are now stuck with a VM on that machine, ssh into it, etc. Or another remote machine/VM which can be even more complicated.
theupandup (3 months ago)
sidenote the pretentiousness of people in tech is my biggest pet peeve. just because you like something a certain way doesn't mean other people are wrong or stupid for preferring something different. it's like there's a lack of empathy or social awareness rampant in this field.
theupandup (3 months ago)
because I like running windows applications/using windows OS while I'm programming. I used virtual machines for a while to achieve this end but it was clunky and annoying to work with, and just using the linux bash for windows is better for me for what I'm doing. I like a lot of windows applications, but I do not like windows for development. I imagine it isn't that rare.
bqumba1 (7 months ago)
Don't judge others' moms by yours.
Jack Spencer (11 months ago)
Scott, this is EXACTLY what I was looking for - trying to understand how to use VSCode and edit files on Windows 10, but running them on Linux. Thank you sir! I don't know what Microsoft is paying you, but they should DOUBLE it.
MTech over9000 (11 months ago)
Thanks bro, I was getting annoyed that files I edited in Notepad++ were disappearing in my ubuntu partition
eugene santos (11 months ago)
How were you able to fire VSCode inside the wsl? isnt that an .exe file?
Rhuan Pacheco (10 months ago)
He fired VSCode in Windows not inside Linux.
Nathaniel Orton (11 months ago)
Doesn't work for me./mnt/c/Program Files/Microsoft VS Code/bin/code: line 7: realpath: command not found /mnt/c/Program Files/Microsoft VS Code/bin/code: line 14: ./Code.exe: No such file or directory
Mr Claytron (11 months ago)
WSL is smart enough to be able to run windows exe files from within the linux environment... and likewise, you can actually run linux commands directly from a CMD or Powershell terminal. You can even create a bash instance directly in your Powershell window - just type 'bash'. I've been playing around with this a bit lately, and its pretty amazing... I'm running Node.js on WSL, and doing editing in VSCode... even more awesome, you can even set the VS Code built in terminal to use bash! Windows is without doubt the number one platform for developers now in my opinion. I'm very interested to see where Microsoft takes this... its just awesome!
Jimmy Pack (1 year ago)
Its kind of incredible.. just saying.
Justin Hoover (1 year ago)
Do chroot jails work with this method? I have some super old fucking OpenSuse toolchains that I would love to target with the power of my workstation for builds... if that would work... ho-lee-shit.
hellrover (1 year ago)
Thank you!
Bassil Redman (1 year ago)
Suppose I install git for windows and also do sudo apt install git on WSL... what happens then? which git would I be using?
Balaji S (10 months ago)
VSCode can't point the git.Path to WSL git $(which git) at the moment. But they are working on it
Tech Store (1 year ago)
It should be the later one
Alan Flint (1 year ago)
Have everything setup like you - GETTING ERROR when using 'rails generate controller' alanflint@XXXXXX:/mnt/c/Users/Alan/rails_code/Sites/myrubyblog$ rails generate controller home index /home/alanflint/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/app_loader.rb:40: warning: Insecure world writable dir /home/alanflint/.rbenv/versions in PATH, mode 040777 and just has a blinking cursor waiting for me to type
Efim Losev (1 year ago)
so what are benefits for using it instead msys2 for example?
Bassil Redman (1 year ago)
you can run many more linux apps, not just what is in the msys2 package repository
Ewie M (1 year ago)
Do MacOS next.
Bob Hulling (1 year ago)
Yea I see that it is more that just a PM, but was just mentioning Homebrew as it provides the convenience of something like apt-get. I guess in my case that would be my main use for WSL. P.S. Libre Office on mac is pretty good, I use it quite often mostly for Calc.
Ewie M (1 year ago)
WSL is a lot more than a package manager. it's less than WINE was (or is) but it's not clear how much less, For instance I've run some simple Linux editors on WSL like Kate and Geany. They both have some interesting issues but they both run. But i'm sure I couldn't run something like open office. That's fine because it's only intended to support command line programs. So why not the same for MacOS? (If Apple would even allow that :)
Bob Hulling (1 year ago)
There is Homebrew if you're just wanting a nice package manager.
Mark Pitman (1 year ago)
@shanselman How did you get "code ." to work from bash?!? Did you have to setup an alias?
hacky33 (9 months ago)
Where can I modify profile_bash or .bashrc??
jjuel5 (1 year ago)
I think you can just add '/mnt/c' to your path that is if Code is installed on your c drive.
foofighterdaz (1 year ago)
Note, any alias established will be for the current terminal session only
foofighterdaz (1 year ago)
Yes, you use: alias code="/mnt/c/path/to/code" Amazing tip for flying around the OS
Michael Powell (1 year ago)
Can this "user mode Linux kernel" be installed on Windows 7?
Tech Store (1 year ago)
Lol.. People are still sucking Windows 7's dick
Scott Hanselman (1 year ago)
Michael Powell no, it's Windows 10 only
I recently got a new notebook at office and it has Windows 10 running inside.I am trying to use Linux subsystem, but faced some problems since linux subsystem and Windows Store do not work behind a proxy.
When I turn IE proxy off and connect directly (through wifi network, which allows me to) errors are gone.
On Windows Store I am getting "Code: 0x80070057" and for some apps "Code: 0x80240438". I must confess these error codes are cryptic for me. As for the bash on Windows 10 I am getting errors like the following: root@N003407:~# sudo apt-get update sudo: unable to resolve host N003407 Ign http://archive.ubuntu.com trusty InRelease Ign http://security.ubuntu.com trusty-security InRelease Ign http://archive.ubuntu.com trusty-updates InRelease Ign http://archive.ubuntu.com trusty-backports InRelease Err http://security.ubuntu.com trusty-security Release.gpg Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1560:8001::14). - connect (101: Network is unreachable) [IP: 2001:67c:1560:8001::14 80] Err http://archive.ubuntu.com trusty Release.gpg Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8001::17 80] Ign http://security.ubuntu.com trusty-security Release Err http://archive.ubuntu.com trusty-updates Release.gpg Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8001::17 80] Err http://archive.ubuntu.com trusty-backports Release.gpg Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::17). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8001::17 80] Ign http://security.ubuntu.com trusty-security/main amd64 Packages/DiffIndex 12% [Connecting to archive.ubuntu.com (] [Connecting to security.
Thanks for replying. I am not able to run commands like "sudo apt-get [update|upgrade|install]" and download/install applications through Windows Store. I will send you further information tomorrow morning when I am at office.
Scott Hanselman (1 year ago)
Luciano Evaristo Guerche they work here behind a proxy. Can you be more specific? Is your proxy actively blocking the store? Is the proxy configured in IE?
Amazing feature!!! I remember spending an entire weekend trying to configure the EFI with dual boot in my laptop.
Jared Thirsk (1 year ago)
One thumbs down vote. Ballmer is that you?
monkh (1 year ago)
So do i need to isntall linux version of vscode or is it running windows version of vscode?
dauchande (1 year ago)
He was using the windows version of vscode.
Dave Van den Eynde (1 year ago)
So why didn't they just point ~ to /Users/user ?
James Makumbi (1 year ago)
I feel sooooooo stupid. I have long wondered how to edit source files in windows (visual studio) used in linux (python) and it never for once even crossed my mind to create the linux project in my visual studio project folder. Now it is common sense. Linux can see windows but windows should not see linux. I might even create a shallower file path on my data drive just for linux projects I want to code with windows tools. Thanks Scott.
Brad Christie (1 year ago)
indeed, the key difference is to use mnt. if you don't, bash won't see anything not created by itself (permission issues). you could `touch file` then modify it in Windows, but that creates horrible artifacts.
Alex Leibowitz (8 months ago)
Damn it, this is what I've been doing...
Brad Christie (1 year ago)
Hassan Selim you end up with the two out of sync woth each other, esp noticeable when you go to blow it up and rebuild.
Hassan Selim (1 year ago)
what kind of horrible artifacts? O_o (I did that once)
Cel sun (1 year ago)
thanks for your effort, but still have problem with bash, if u start to install packages at 50% or less it will freeze, when u want to close the shell it will freeze, if u restart your pc, and want to run bash it will never work
Cel sun (1 year ago)
can y please help me with some names of packages that are available or pen-testing and finding vulnerabilities and some packages for web development or app development, the first video i have ever watch on bash shell was yours, and the 19 mins video was well explained
Cel sun (1 year ago)
thanks Scott
Scott Hanselman (1 year ago)
Nmap is a little lower level and it's being worked on. Other than nmap, 99% of things works fine.
Cel sun (1 year ago)
i am running bash shell, like if in want to install nmap, and i enter sudo get install nmap, it qwill start to install when it reaches 50% it will freeze, it will take some days on that 50% if i want to close the bash shell, it will not except i restart my pc, after restarting if i want to open the bash shell trust me it come on the desktop within 1 second the shell is gone
Scott Hanselman (1 year ago)
I'm not seeing that at all, and I'm in bash hours a day. What does "top" say when you "freeze"?
tazoo14 (1 year ago)
thanks Scott

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.