Philipp Burckhardt

On Statistics, Programming and the Social Sciences

Unix Shell in Windows via Cygwin

With PowerShell, Windows does offer a very nice terminal, but I often find myself trying to use UNIX commands as I ten to switch between Windows and Ubuntu for my daily work.

Although this is probably cold coffee for most people, I only recently discovered Cygwin, a collection of tools which provide a Linux-like experience when using a terminal.
Further information about Cygwin as well as a download link can be found under

https://www.cygwin.com/.

After downloading, launch the installer. Let us install Cygwin in the default directory:

Cygwin installer

After that, one will be asked to specify a directory into which the packages should be downloaded. Again sticking with the default choice, one is then asked to select a mirror for downloading. Afterwards, one is presented with a choice which packages should be installed for use in the terminal:

Cygwin installer2

Unlike on Linux, it is not possible to install new software in Cygwin via a command such as apt-get install. Instead, one has to re-install Cygwin via this installer and select the appropriate package. One might want to consider installing all possible software, which can be done by clicking on the "default" button next to "All" in the menu printed above. However, downloading the necessary files will take a long time and consume a lot of space, as the data totals more than 11 gigabytes.

After installation, one can either use the Cygwin terminal or the Windows PowerShell. Since npm and node do not work with the former, I personally do not use it but stick to the Windows-supplied terminals. To make Cygwin available to the default terminals, we add

C:\cygwin64\bin

to the Path environment variable (or whatever custom root directory you have chosen during installation). These can be accessed under System > Advanced System Settings. Just append it after separating it from the other elements in PATH via a semicolon:

Environment Variables

Now, we should be able to use UNIX commands inside our Windows terminal.