Social Icons

twitter facebook google plus linkedin rss feed email



Sunday, June 4, 2017

18 things you should know about using Linux tools in Windows 10

Last year Microsoft added an unusual new feature to Windows 10: Linux support. The Windows Subsystem for Linux (WSL) — sometimes called Bash on Windows — is “Microsoft’s implementation of a Linux-compatible infrastructure that runs atop and within the Windows kernel,” senior program manager Rich Turner tells CIO.com. That means running Linux binaries without leaving Windows.
“Bash on Windows offers a toolset for developers, IT administrators and other tech professionals that want or need to run Linux command-line tools alongside their Windows tools and applications,” Turner explains. Developed with the help of Canonical (and a large community of Linux users), it’s not there to turn Linux into Windows, or Windows into Linux. It’s just that some Linux tools are so ubiquitous for development and deployment that it’s useful to be able to use them without spinning up a virtual machine (VM). That’s one of the reasons Macs are so popular with developers: MacOS is based on BSD, which is UNIX, so it can run Linux tools like Bash. And now, so can Windows 10.
“Using Bash on Windows, developers can run genuine, unmodified Linux command-line tools within a highly-compatible Linux environment, alongside their favorite Windows productivity and development tools,” Turner explains. Think Office and Vi or PowerShell and grep, side by side.
WSL is evolving fast and with Creators Update, Turner says it’s good enough for everyday use. But it’s easier to use once you understand a few things about the way Windows 10 and Linux interact.

1. It's for developers
2. WSL is a Linux distro, not a Linux kernel
3. It's not a virtual machine
4. It's not Cygwin
5. How to install and start it
6. You don’t need an admin account to use it
7. Even symlinks don’t need admin rights
8. It's not just bash
9. It's for command-line tools, but…
10. Adding Linux support has improved the console for everyone
11. It's not on Windows Server
12. Bash doesn't replace PowerShell
13. You need to manage updates
14. You can (mostly) manage WSL with your usual Windows tools
15. It cross connects with Windows processes
16. It cross connects with the Windows filesystem
17. You can’t open Linux files in Windows apps
18. You’ll want to be on Windows Insider

WSL is there to make Windows work better for developers who need to connect easily to a Linux backend, or use tools that are often available on Linux and not on Windows, or where those tools have been compiled to binaries that assume you’ll be using Linux, with the Linux filesystem. Turner calls it “a great toolset for any developers working on multi-platform solutions, especially those working on building web sites and services, distributed systems or storage services.”
WSL installs a Linux distro on your PC (currently, Ubuntu 16.04 is the distro you get automatically and that what's supported, although more options will be available in future). The Linux binaries make their system calls as usual but, Turner explains, those syscalls just go to the Windows kernel instead. “Calls from user-mode command-line tools interact with the OS kernel,” says Turner. That means you just install and use Linux binaries without needing to change anything because you’re on Windows.
When you run Linux on Windows in a VM, you get a separate operating system that bypasses a lot of Windows. WSL uses much less CPU and memory than a VM, and because you’re still in Windows you can use Windows and Linux tools side by side on the same set of files. That also means it will work in a Windows VM, without having to worry about nested virtualization.
Cygwin is a library that gives you a UNIX-like graphical environment inside Windows, including a command-line interface, and you have to compile software specifically for it. With WSL, Linux binaries open inside the standard Windows environment, and you don’t have to modify them to run on Windows.

You need a 64-bit version of Windows 10 Creators Update (version 1703 or later). First open Settings > Update & security For developers and turn on Developermode, then select the checkbox marked Windows Subsystem for Linux (Beta) in the Turn Windows features on or off control panel (you can also type this into an elevated PowerShell window: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux). Restart your PC, open a command prompt and type bash to download the Ubuntu image; this also adds a shortcut to the Start menu that launches bash. The first time you use it, you’ll be promoted to create a UNIX username and password (this is a different account from your Windows account).
You do need admin credentials to turn on WSL, but that can be done with DISM or other management tools, so developers who don’t have admin accounts on their PCs can still use WSL once it’s been enabled.
Windows has supported symbolic links since Vista, but for security reasons you’ve had to use an elevated command prompt to create and modify them. That causes problems for tools like Git and npm, which use symlinks when creating and restoring repos and packages. As of Creators Update, once you’ve turned on Developer mode, you don’t need to elevate form admin to work with symlinks.
Bash is the way into WSL; it’s always the first WSL process that runs and if you close bash, all the other Linux processes you’re running will close as well. But you can use apt in bash to install Linux binaries. You can use other shells like zsh and fish, you can use common Linux tools like apt, sed, grep, awk, top, tmux and ssh, you can use developer tools like Vim, Emacs, git and the GNU Debugger (GDB), you can run services like sshd, Apache, nginx, MySQL and PostgreSQL, and you can run language tools like npm for Node.js, gems for Ruby, Apache Maven for Java, Pip for Python and whatever else you’d usually use on Ubuntu.
WSL is designed for running command-line tools, which is why it starts with the bash shell. But that doesn’t mean graphical Linux tools won’t work at all. In fact, many do work, but that’s a side effect of the work Microsoft is doing to support command-line tools, not the reason WSL is there. Microsoft isn’t doing anything specifically to support running graphical Linux tools, but, equally, it isn’t doing anything to stop you running them on WSL if they work for you.
To make the Windows console handle text formatting well for command line tools like Vim, Emacs and tmux, Creators Update has better support for the ANSI codes and VT Sequences that UNIX and Linux tools use in their interfaces. It also has 24-bit color rather than the old 16 colors and better mouse support (needed by tools like Midnight Commander and Htop), and those show up in all the Windows command-line interfaces, including CMD and the PowerShell console.
WSL is only included in the Windows 10 client, not in Windows Server. So if you’re using virtual desktop infrastructure (VDI) or other ways of running Windows sessions, you need to be running the Windows client to be able to use WSL.
One reason that WSL isn’t on Windows Server is that it’s not designed to manage workloads like Windows Server, Active Directory, IIS, Exchange, SharePoint, System Center, SQL Server, Hyper-V and Azure the way PowerShell is. PowerShell is a task automation and configuration framework, not just a shell, and WSL doesn’t change that.
WSL gets updated regularly through Windows Update and with the twice-yearly updates to Windows. But that (based on strong feedback from users) doesn’t update your Linux distro. To get updates to Ubuntu and the various Linux binaries, you have to run apt-get update yourself (although Microsoft plans to add a way to automate this in time).
One big advantage of WSL is that you can use the same network monitoring and management tools that you already use for your Windows systems, something that VMs often bypass. “Since WSL utilizes the Windows kernel’s existing memory, process, network, storage, networking and IO stacks, the investments that companies have made in OS protection, management and monitoring are preserved and extended to help protect, monitor and control Linux processes,” Turner explains. So far Windows Defender is the only anti-virus that works with WSL and monitors your Linux processes, although he says “many other anti-malware providers are already working with Microsoft to update their products to add support for WSL.”
The Linux processes you run with WSL are treated like any other process in Windows, so they show up in Task Manager, giving you an easy way to kill any processes that have hung. That also means you can call Windows executables from within bash just by typing the full, case-sensitive filename of the program (remember the .EXE, but you don’t need to specify where the file lives if it’s on the Windows path), or call Linux binaries and get the output from a Windows app. That means you can start batch files from bash by calling CMD.EXE, pipe the output of a command in bash to PowerShell to process it, or launch Visual Studio or call a tool like MSBuild to build the code you’ve just finished editing right from bash. Install the RunInBash command-line helper to run Linux commands from PowerShell or CMD by typing $ in front of it.
With WSL you get a Linux DrvFs filesystem, and any permanently attached drives from the Windows filesystem are automatically mounted into that, so that you can access files on your Windows system from Linux tools that you run. WSL even supports the Linux inotify service, which allows apps to register for filesystem change notifications, including files in the Windows filesystem, and those notifications can trigger actions, like restarting a server or building your code. That means you can keep your code where you can edit it with Visual Studio, use the same code with Linux tools and automate what happens when you change it either way.
Linux tools running with WSL can open Windows files, but don’t try to open files from the Linux filesystem in Windows apps. It won’t work and can damage the files.
WSL is still developing and keeps getting new features, like connecting to Windows serial ports from Linux processes or being able to mount removable drives and network shares. Those weren’t in Creators Update, but you can get them without waiting six months for the next big update by running Windows Insider builds.
This story, "18 things you should know about using Linux tools in Windows 10 " was originally published by CIO.

Hey My Readers and Visitirs If You Like Us or Our Web Site Please Share and Link back To My Site ... Take Care .,.,.



0 comments:

add

Related Posts Plugin for WordPress, Blogger...
 

Google Analystic

add block