Wsl github bash on windows
The tutorial will tell you how to run desktop environment inside Windows Subsystem for Linux. And you don’t need to build a developement environment with virtual machines any more. 🙂
Your PC must be running a 64-bit version of Windows 10 Anniversary Update build 14393 or later.
To find your PC’s CPU architecture and Windows version/build number, open Settings>System>About. Look for the OS Build and System Type fields.
In order to run Bash on Windows, you will need to manually:
1.Turn-on Developer Mode
2.Enable the “Windows Subsystem for Linux (beta)” feature
After enabling Windows Subsystem for Linux
1.Restart your computer
After you have accepted the License, the Ubuntu user-mode image will be downloaded and a “Bash on Ubuntu on Windows” shortcut will be added to your start menu.
Install the lastest version of VcXsrv.
Install xfce desktop
Specify the display server
Add DISPLAY=:0.0 to your
/.bashrc , and don’t forget to run source
Fix dbus error (Only Ubuntu 14.04) and only if your Windows version is older than 1803
You need to replace
Fix connection refused (Only Ubuntu 14.04) and only if your Windows version is older than 1803
You need to replace
Open display server
Open XLaunch, choose “One large window” or “One large window without titlebar” and set the “display number” to 0. Other settings leave as default and finish the configuration.
Execute the following command inside “Bash on Ubuntu on Windows”.
Fix powerline fonts rendering
Install the lastest version of Hack fonts.
Fix Unicode fonts rendering
Fix Chinese fonts rendering
Fix mkdir command has wrong permissions
Add the following shell code to your bashrc
Install Chinese input method
2.Add the following command to your bashrc file
Install drop-down terminal
How to shutdown wsl
2.Exit “Bash on Ubuntu on Windows”
Please enjoy your development environment. 🙂
About
A tutorial about how to run desktop environment inside Windows Subsystem for Linux
Resources
Releases
Packages 0
Contributors 4
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Wsl github bash on windows
Launch Windows programs from «Bash on Ubuntu on Windows» (WSL)
NOTE: WSL in Windows 10 Creators Update (version 1703) can natively launch Windows programs. I recommend that you try it and use it if you can. Cbwin remains available for people using WSL on Windows 10 Anniversary Update (version 1607) — and will also continue to run on version 1703.
main cbwin features:
- Win32 command line tools in the console, invoked from WSL
- Win32 command line tools with redirections to WSL (stdin/stdout/stderr to or from pipe/file)
- suspend/resume propagation (Ctrl-Z suspends the Win32 processes, fg resumes them)
- exit codes propagation
- launch «detached» GUI Windows programs (uses start of cmd )
Using cbwin breaks the WSL security model (access control within WSL using Linux accounts): Windows programs are not subject to extra WSL security checks, so the capability to run a Windows program is equivalent to being root in WSL. If you are only using separation between the WSL root and user to avoid casual mistakes and not for strong security purposes this is not an issue. (Note that being root under WSL does not give you any Windows administrator rights.)
Running elevated WSL processes can reduce the effectiveness of UAC, see this issue. Elevated instances of outbash.exe do not allow non-elevated callers to launch processes, but it is easy for non-elevated WSL processes to force elevated ones (present and future) to do anything, including accessing protected Windows files and talking with outbash.exe . Therefore, I do not recommend launching an elevated «Bash On Windows» (with or without outbash.exe ) in an hostile environment, in order not to reduce the effectiveness of UAC.
outbash.exe listens on 127.0.0.1, but validates that processes that establish a connection are running as the same user as outbash.exe — and extra sockets used to forward redirections are connected in a way that prevents interceptions (this is implemented starting with version v0.10). Therefore, it can be used on multi-user computers.
- In the unpacked binary archive, launch outbash.exe
- Do: sudo ./install.sh
- In Windows, copy outbash.exe where you want, usually somewhere in your %PATH%
- In WSL sessions launched by outbash.exe , you can now call Windows programs with the wrun , wcmd , and wstart commands.
- Build outbash.exe with Visual C++ 2015 and use it instead of bash.exe
- In caller/ , build wrun , wcmd , and wstart (with make all )
- Install wrun , wcmd , and wstart in /usr/local/bin (with sudo make install )
- In WSL sessions launched by outbash.exe , you can now call Windows programs with the wrun , wcmd , and wstart commands.
wrun launches a Windows executable (directly with CreateProcess ). wcmd launches a command with cmd.exe . wstart launches a detached command (with start of cmd ).
Windows processes and their children launched with wcmd or wrun are handled in a Windows Job, and suspending the WSL caller process ( wcmd or wrun ) results in the suspension of all the Windows processes in the corresponding Job. Also, when the launched process terminates, all its direct and indirect children are killed. This means that trying to manually do e.g. wcmd start notepad won’t yield useful results, because notepad will be killed just after having been launched — wstart must be used in this case.
If in doubt use wcmd to launch Win32 command line tools, and wstart to launch graphical applications.
You can redirect input and output (avoid doing that with wstart , it would behave weirdly):
The environment block for launched processes is the one outbash.exe was started with, but it can be modified for individual commands. The —env option allows to set environment variables for the command. Parameters after this option are interpreted as environment variable definitions until one starts with » — » or a parameter does not contain an » = » character. An empty value erases the variable. Remaining command line arguments are used to compose the Windows command line. All the options interpreted by the launcher must be given at the start, before the Windows command line.
Other example to launch msbuild to rebuild outbash.exe , which shows that return codes are propagated (running from another copy of outbash.exe , its impossible to overwrite it when in use):
For now, interactive Win32 console tools in the same console as a WSL bash session (for example: wrun cmd or wcmd python ) do not work well. The problems seem to be related to the console switching internal modes (charset, but not only) between the Win32 and the WSL world, and some input being directed to WSL even when there is no need to do so. I don’t know yet if something nice enough to use in that regard can be achieved without some changes from MS about how their stuff works.
It is an unfinished work in progress. There are various stuff not-implemented and maybe tons of bugs.
About
Launch Windows programs from «Bash on Ubuntu on Windows» (WSL)
Wsl github bash on windows
Mintty as a terminal for WSL (Windows Subsystem for Linux).
- wsltty package components (see below) in the user’s local application folder %LOCALAPPDATA%
- a wsltty configuration directory in the user’s application folder %APPDATA% (“home”-located configuration files from a previously installed version will be migrated to the new default location)
- Start Menu shortcuts to start WSL terminals
- *.bat scripts to invoke WSL terminals from the command line
- optional context menu entries for Windows Explorer to start WSL terminals in the respective folder
- install/uninstall context menu items from Start Menu subfolder WSLtty
Since release 3.0.5, WSLtty requires Windows version 1809 (the November 2018 release).
Installation from this repository
WSLtty installer (Download standalone installation)
Run the installer to install the components listed above. If Windows complains with a “Windows protected your PC” popup, you may need to click “Run anyway” to proceed with the installation. You may need to open the Properties of the installer first, tab “General” section “Security” (if available) and select “Unblock”, to enable the “Run anyway” button.
Installation from source repository
Checkout the wsltty repository, or download the source archive, unpack and rename the directory to wsltty . Invoke make (or make pkg if directory is called wsltty-master ), then make install .
Note this has to be done within a Cygwin environment. A minimal Cygwin environment for this purpose would be installed with the Cygwin installer from cygwin.com, with additional packages make , gcc-g++ 9.3.0 , unzip , zoo .
Installation to non-default locations
(For experts) Within the installation process, provide parameters to the script install.bat . The optional first parameter designates the installation target, the optional second parameter designates the configuration directory.
Installation with other package management environments
Note that these are 3rd-party contributions and do not necessarily provide the latest version.
If you use the Chocolatey package manager, invoke one of
- choco install wsltty
- choco upgrade wsltty
- scoop bucket add extras
then, invoke one of
- scoop install wsltty
- scoop update wsltty
Windows Appx package
A Windows Appx package and certificate is available in the wsltty.appx repository.
To uninstall wsltty desktop, start menu, and context menu integration: Open a Windows cmd , go into the wsltty installation folder: cd %LOCALAPPDATA%\wsltty and run the uninstall script. To uninstall wsltty software completely, remove the installation folder manually.
WSLtty can be invoked with
- installed Start Menu shortcuts (or Desktop shortcuts if copied there)
- *.bat scripts (optionally with WSL command as parameters)
- Explorer context menu (if installed from the Start Menu WSLtty subfolder)
Starting the mintty terminal directly from the WSLtty installation location is discouraged because that would bypass essential options.
Terminal communication with WSL via its modes V1 or V2 is handled automatically by wsltty (mintty and the wslbridge2 gateway).
If wsltty fails with an Error: Could not fork child process: Resource temporarily unavailable . its runtime may be affected by some over-ambitious virus defense strategy. For example, with Windows Defender, option “Force randomization for images” should be disabled.
If wsltty fails with an error message that mentions a disk mount path (e.g. /mnt/c ), workarounds may be the shutdown of the WSL V2 virtual machine ( wsl —shutdown on the distro) or turning off “fast startup” in the Windows power settings (#246, #248).
WSL shell starting issues
With WSL V2, an additional background shell is run which may cause trouble for example when setting up automatic interaction between Windows side and WSL side (see https://github.com/mintty/wsltty/issues/197#issuecomment-687030527). As a workaround, the following may be added to (the beginning of) the WSL shell initialization script .bashrc (adapt for other shells):
Start Menu and Desktop shortcuts
In the Start Menu, the following shortcuts are installed:
- Shortcut
WSL Terminal to start the default WSL distribution (as configured with the Windows tool wslconfig or wsl -s )
- For each installed WSL distribution, for example Ubuntu , a shortcut like
Ubuntu Terminal to start in the WSL user home
In the Start Menu subfolder WSLtty, the following additional shortcuts are installed:
- Shortcut
WSL Terminal % to start the default WSL distribution in the Windows %USERPROFILE% home
- For each installed WSL distribution, for example Ubuntu , a shortcut like
Ubuntu Terminal % to start in the Windows %USERPROFILE% home
One Desktop shortcut is installed:
- Shortcut
WSL Terminal to start the default WSL distribution (as configured with the Windows tool wslconfig or wsl -s )
Other, distribution-specific shortcuts can be copied to the desktop from the Start Menu if desired.
The Start menu folder WSLtty contains the link configure WSL shortcuts . This function is initially run when wsltty is installed. If should be rerun after adding or removing WSL distributions, in order to create the respective set of shortcuts in the Start menu.
Command line scripts wsl*.bat
WSLtty installs the following scripts into %LOCALAPPDATA%\Microsoft\WindowsApps (and a copy in its application folder %LOCALAPPDATA%\wsltty ):
- For each installed WSL distribution, e.g. Ubuntu, a command script like Ubuntu.bat to start in the current folder/directory
- For each installed WSL distribution, e.g. Ubuntu, a command script like Ubuntu
.bat to start in the WSL user home
WSL.bat and WSL
.bat to start the default WSL distribution
Given that %LOCALAPPDATA%\Microsoft\WindowsApps is in your PATH, the scripts can be invoked from cmd.exe, PowerShell, or via WIN+R.
Context menu entries
WSLtty provides context menu entries for all installed WSL distributions and one for the configured default distribution, to start a respective WSL terminal in a specific folder from an Explorer window. They are not installed by default.
To add launch entries for the default or all WSL distributions to the Explorer context menu, or remove them, run the respective script from the Start Menu subfolder WSLtty :
add default to context menu adds context menu entries for the default WSL distribution
add to context menu adds context menu entries for all WSL distributions
remove from context menu removes context menu entries for WSL distributions
Wsltty installation and the mintty terminal try to use the icon of the respective WSL distribution. If it cannot be determined, a penguin icon is used as a default. You can replace it with your preferred fallback icon by replacing the icon file %LOCALAPPDATA%\wsltty\wsl.ico .
Mintty can maintain its configuration file in various locations, with the following precedence:
- file given with mintty option -c (not used by wsltty default installation)
- file config in directory given with mintty option —configdir
- %APPDATA%\wsltty\config in the default wsltty installation
- %HOME%\.minttyrc (usage deprecated with wsltty)
- %HOME%\.config\mintty\config (usage deprecated with wsltty)
- common config file for all mintty installation instances
- %APPDATA%\mintty\config
- %LOCALAPPDATA%\wsltty\etc\minttyrc (usage deprecated with wsltty)
- %APPDATA%\wsltty\config is the user configuration file location. Further subdirectories of %APPDATA%\wsltty are used for language, themes, and sounds resource configuration. Note the distinction from %LOCALAPPDATA%\wsltty which is the default wsltty software installation location.
- The %APPDATA%\mintty\config option provides the possibility to maintain common mintty settings for various installations (like wsltty, Cygwin, MinGW/msys, Git for Windows, MinEd for Windows).
- (About deprecated options) By default, %HOME% would refer to the root directory of the cygwin standalone installation hosting wsltty. So %HOME% would mean %LOCALAPPDATA%\wsltty\home\%USERNAME% . If you define HOME at Windows level, this changes accordingly. Note, however, that the WSL $HOME is a completely different setting.
Shell selection and Login shell
The WSLtty deployment does not impose a shell preference; it invokes the user’s default shell in login mode by the final — parameter:
- %LOCALAPPDATA%\wsltty\bin\mintty.exe —WSL= —configdir=»%APPDATA%\wsltty» —
You may tweak shortcuts, scripts, or context menu entries as follows:
To launch a default shell in non-login mode, remove the final dash.
To invoke your preferred shell, replace the final dash with a shell pathname and an optional -l parameter
- %LOCALAPPDATA%\wsltty\bin\mintty.exe —WSL= —configdir=»%APPDATA%\wsltty» /bin/bash -l
Components and Credits
For mintty, see the Mintty homepage (with further screenshots), the Mintty manual page,
and the Mintty Wiki, including a Hints and Tips page.
It is based on Cygwin and includes its runtime library (sources).
For interacting with WSL, wslbridge used to be the gateway prototype. Many thanks for this enabling gateway go to Ryan Prichard.
For recent changes in WSL, particularly WSL mode V2, the new gateway wslbridge2 is used instead. Many thanks for this further development and maintenance go to Biswapriyo Nath.
About
Mintty as a terminal for Bash on Ubuntu on Windows / WSL