Saturday, May 4, 2019

Built-in Unix tools on Windows 10

As you may be aware, Windows 10 supports running a full Linux/bash environment via the Windows Subsystem for Linux (WSL). This can be installed from the Windows Store, or via PowerShell, and gives you access to the tools provided by your chosen distribution without the need to reboot or start up a VM.

However, Windows 10 also (as of April 2018) includes a few very useful tools without even needing to enable the WSL. These tools are:

  • ssh - "Secure SHell", allowing you to access Linux, Unix, macOS, and other related operating systems remotely from the command line
  • curl - "Client URL", which you can use to upload/download files and make requests to web servers from the command line
  • tar - "Tape ARchive", which allows you to combine many files into one archive for ease of transport and/or compression
These tools are now included and enabled by default in Windows 10, and can be accessed from either cmd.exe or PowerShell. One difference between these two shells is in the curl command: in cmd.exe, this runs as a regular executable, with the same flags that you would expect on a Unix machine; however, in PowerShell, curl is an alias to the Invoke-WebRequest cmdlet, so its arguments are not the same. You can get around this by specifying curl.exe in PowerShell to get the standard behavior.

These tools, ssh in particular, are very useful in my daily work as they allow me to remote into Macs without needing to have PuTTY or some other terminal installed. tar is also useful because it helps reduce the slowness you may encounter when copying many small files; by combining these files into one larger archive, you can avoid the time overhead required to start and stop the copying operation for each, only paying that time penalty once.

These tools are also useful for scripting, even (or especially) in batch files. PowerShell provides cmdlets that replicate the functionality of curl, for example, but now that it's included by default, you can easily write a plain old .bat file to download a file from a website, or even to make a HTTP request to a server by POSTing to a URL.

No comments:

Post a Comment

Tableau, TabPy, and the Case of No Input Rows

 I haven't scientifically confirmed this or anything, but it sure seems like if you pass an empty dataframe to a TabPy script, then no m...