User Tools

Site Tools


windows:wsl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
windows:wsl [2019-02-18 01:14] – adding some detail gabrielwindows:wsl [2019-08-18 22:18] – [Using ssh-agent with multiple shell sessions] updated to include check for open shells gabriel
Line 1: Line 1:
-====== Enabling and installing Windows Subsystem for Linux ======+====== Windows Subsystem for Linux ======
  
-Run the following in an administrative PowerShell:+To enable and [[https://docs.microsoft.com/en-us/windows/wsl/install-win10|install]] 
 +[[https://docs.microsoft.com/en-us/windows/wsl/faq|Windows Subsystem for Linux]] on Windows 10, run the 
 +following in an administrative PowerShell:
  
 <code> <code>
Line 7: Line 9:
 </code> </code>
  
-You will be prompted to reboot.  After rebooting, you can install your favorite Linux distribution(s) via the Microsoft Store.+You will be prompted to reboot.  After rebooting, you can install your favorite Linux distribution(s) via the 
 +Microsoft Store. 
 + 
 +===== Disable audible bell on terminal ===== 
 + 
 +Uncomment the following lines in ''/etc/inputrc'': 
 + 
 +<code> 
 +# do not bell on tab-completion 
 +set bell-style none 
 +set bell-style visible 
 +</code> 
 + 
 +===== Using ssh-agent with multiple shell sessions ===== 
 + 
 +WSL doesn't run a full Linux system, rather it acts as an translation layer that can emulate the software 
 +interface required to run native Linux applications in the Windows kernel.  Among the implications of this 
 +implementation is the fact that there is no good way start an ssh-agent session that is automatically shared 
 +all shell sessions in the same manner as a native Linux desktop. 
 + 
 +These hacks allow successive shells to attach to the ssh-agent socket started by your first session. 
 + 
 +These commands should be inserted in ''~/.bashrc'': 
 + 
 +<code> 
 +# start ssh-agent for WSL 
 +SSHAGENTINFO=/tmp/${USER}-ssh-agent/conf 
 +if [ -f $SSHAGENTINFO ]; then 
 +  printf "Reading ssh-agent socket info from %s.\n" $SSHAGENTINFO 
 +  source $SSHAGENTINFO 
 +else 
 +  (umask 0077 ; mkdir -p `dirname $SSHAGENTINFO`; ssh-agent > $SSHAGENTINFO) 
 +  source $SSHAGENTINFO 
 +fi 
 +</code> 
 + 
 +To make sure that the session gets cleaned up, insert this in ''~/.bash_logout'': 
 + 
 +<code> 
 +# shut down our ssh-agent when we close the final shell 
 +SHELLPIDS=$( pgrep bash ) 
 +SHELLCOUNT=$( echo $SHELLPIDS | wc -w ) 
 +if [[ $SHELLCOUNT -eq 1 ]]; then 
 +  ssh-agent -k && rm -f /tmp/${USER}-ssh-agent/conf 
 +fi 
 +</code>
windows/wsl.txt · Last modified: 2019-08-18 22:20 by gabriel