The Windows Subsystem for Linux (WSL) seems to be mature enough now to give it another shot. Copy and paste, and other simple annoyances that kept me away before are working better. Also, I’ve been reading that nvm (Node Version Manager) works now, so here goes.
As a precursor, note that my system is Windows 10 Professional (version 1709, build 16299.309) and is fully up to date with WSL enabled and Ubuntu installed from the Windows Store.
If it has been a while, first thing I like to do with the Ubuntu app is update and upgrade the ubuntu Linux packages. First update the package database with
apt-get update, then upgrade with
apt-get upgrade or
apt-get dist-upgrade. I prefer
apt-get dist-upgrade since it will remove obsolete packages and add new ones as needed.
- Windows update does not change the WSL Ubuntu installation. To upgrade to a new release, run
sudo do-release-upgradein the Ubuntu Terminal.
Oh My Zsh
Oh My Zsh will spruce up your Ubuntu bash and add some additional functionality. Here is a screenshot of my Ubuntu app to illustrate.
Install Oh My Zsh just as you would on any other ubuntu system. Note that Zsh is a pre-requisite. For installation instructions and more information, visit https://github.com/robbyrussell/oh-my-zsh.
Your going to want to change the font to fix unknown character issues. I’ve installed the DejaVu Sans Mono for Powerline font available here.
- To set WSL Ubuntu bash with zsh as your integrated terminal in VS Code. Update your user settings file, e.g.,
%appdata%\Code\User\settings.jsonwith the following.
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe", "terminal.integrated.shellArgs.windows": ["-c", "zsh"]
If you want to use your existing git and/or other ssh keys, copy them from their folder in Windows into a
.ssh folder under ubuntu. For example,
cd ~/ mkdir .ssh # navigate to Windows .ssh folder, e.g., cd ../mnt/c/Users/Gilfoyle/.ssh # copy the keys into ubuntu .ssh folder cp id_rsa ~/.ssh/ cp id_rsa.pub ~/.ssh/ # set permissions on the private key for github chmod 600 ~/.ssh/id_rsa
nvm is a utility for installing and managing multiple versions of node.js.
Install as an Oh My ZSH! custom plugin by cloning
zsh-nvm into your custom plugins repo.
cd ~/.oh-my-zsh/custom/plugins git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
Then load as a plugin in your
.zshrc profile. Note that plugins need to be added before
oh-my-zsh.sh is sourced. For example, here is a snippet from my
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. plugins=(git) plugins+=(zsh-nvm) source $ZSH/oh-my-zsh.sh
- If you want to install Yarn, use
apt-get install --no-install-recommends yarn. By default, Yarn installs nodejs as a system-wide dependency.
After updating your
.zshrc profile to load the
nvm plugin, close and re-open the Ubuntu app and to install nvm when the plugin is loaded for the first time.
One the install has completed, you can verify by running
nvm which should output the
nvm --help contents.
Install the latest LTS version of Node.js which at the time of this writing is version 8.11.1
# install node nvm install 8.11.1
- If you want to upgrade npm, use
Bash-Snippets collection of bash scripts.
apt-get install fortune apt-get install cowsay apt-get install htop
Mount a drive such as a USB flash drive formatted as FAT, ExFAT or NTFS. For example, a drive listed as
F:\ in Windows would be mounted as follows.
mkdir /mnt/f mount -t drvfs f: /mnt/f
Bind a custom mount for any drives you want to access. For example, the
C drive. This is also required should you want to use Docker volume mount paths as described in this post by Nick Janetakis.
mkdir /c mount --bind /mnt/c /c # unmount umount /mnt/c
- Included in Windows 10 version 1803 (April 2018 Update) is support for WSL launch configuration. The
/etc/wsl.conffile contains settings for drive mounting and network configuration. Read the Microsoft Developer blog post, Automatically Configuring WSL for more information on how to use
If you want to browse the files using Windows Explorer and/or backup the root file system, the location of these files is in the hidden AppData folder. For example:
From Rich Turners blog post …
More info available at WSL File System Support.