Sunday, October 14, 2018

"Bash On Ubuntu On Windows 10" - Take Advantage Of Ubuntu Utilities On Windows 10

Microsoft has recently released "Bash On Ubuntu On Windows 10" - an interface environment that has most of the functionality and tools of the Linux CLI. You can run grepawkand many other tools directly on windows without having to switch over to the Linux environment.
Even if you have never tried Unix or Linux, here is an opportunity to experience and learn with Bash and other NIX tools on Windows 10. In this tutorial, we'll share the way to get started. with Bash on Windows 10 and use them in a variety of ways.
What is "Bash On Ubuntu On Windows 10"?
Bash (Bourne Again Shell) is a shell and programming language for the Unix and Linux platforms. "Bash On Ubuntu On Windows 10" is an optional feature available for Windows 10's user Anniversary.
Bash runs on Windows subsystem for Linux (WSL) and allows you to experience Linux right on your Windows PC.
This is a new technology that allows the NIX command and command-line tool to be native to Windows. You no longer need to install Parallel Unix or Linux with Windows or install Virtual Machine Installer for NIX OS.
Compared to virtual machines, "Bash On Ubuntu" requires less system resources, and allows you to access both Windows and Linux tools at the same time.
Bash on Windows 10 is especially useful for programmers and system administrators working on open source projects. This feature is a surprise gift from Microsoft, with the support of Canonical.
With Bash, the distance between licensed Windows and free and open source Linux technologies has been reduced to the maximum.
Strengths:
  • Runs the NIX command-line utility grepawkandsed
  • Run shell script (.sh) with the help of command-line utility
  • Browse and customize system files in Windows with Bash
  • Try out many NIX tools and utilities like Python, Ruby, Git, ect.
  • Support for server tools like Apache HTTP Server, MySQL, ...
Weakness:
  • The GUI tool has limited compatibility (can be fixed with some tips below).
  • Bash scripts are not allowed to run Windows programs, and vice versa.

How to install "Bash On Ubuntu On Windows 10"
"Bash On Ubuntu On Windows 10" can be installed if the system runs Windows 10 with an update update (build 14393 or later)  and has a 64-bit processor. Follow these steps to make sure your system meets the requirements:
  1. Open Settings> select System> select About
  2. Find the following information: OS Build and System type
After checking the required requirements, you can install Bash through the following steps:
  1. Open Settings > choose Update & Security > choose For developers
  2. Under Use developer features> select Developer mode, Windows 10 will search and install the programmer support package.
Note: Bash is still installed despite the error shown below.
  1. After successful installation of Windows Subsystem for Linux, restart the computer if required.
  2. In the Start search box, type "cmd" and open "Command Prompt"

  1. Type "bash" in the Command Prompt window and hit Enter

  1. Type "y" to agree to the terms (you can see the link if you want).
  2. Windows Subsystem For Linux will load, install Bash On Ubuntu, and create access shortcuts in the Start Menu.
  3. Once Bash is installed, you will need to create a UNIX account (including your username and password)
Note: There is no need to be the same as your Windows account and password
Congratulations! - You have successfully installed Bash On Ubuntu on Windows 10. Now you can use it by accessing the Start Menu and enjoying the utilities provided by Unix and Linux.

How To Use Bash On Ubuntu On Windows 10?
After the installation process, you can use Bash with the highest permissions available on Windows 10. System files (C drive) are placed in the directory /mnt/cin a shell environment, similar to drivers.
Note: Like the * NIX system, Bash on the Windows 10 environment also distinguishes normal Chinese characters, ash, ash, ash, and ash are viewed. are different names.

How to install more * NIX tools and utilities?
You can install additional software or update existing tools by using the command line apt-get, with sudorunning as root or admin on Windows.
Here is a list of the apt-get command lines you can use to install the * NIX software:
  • sudo apt-get update - Update list information packages (the list of available software as well as the version of it)
  • sudo apt-get install <package-name> - Install new applications (replace "<package-name>" with the name of the software to install)
  • sudo apt-get remove <package-name> - Remove the current application (replace "<package-name>" with the name of the software to be removed)
  • sudo apt-cache search <query-word> - Search for available packages (replace "<query-word>" with package name to find)
  • sudo apt-get upgrade - Download and update installed software packages
After downloading and installing the application, you need to type their name into the Bash shell (outside the extension) and hit enter to run.
Note: Restricted Linux tools and utilities only run on the Bash shell.

How to run Bash Scripts?
In the Bash shell, you can use nanoor vieditor to create shell scripts. After creating the script with the required commands, save and exit the editor, then follow these steps to run the command-line script:
  1. Run Scripts using the command chmod, for example, chmod + x ./myscript.shfor scripts named "myscript.sh".
  2. Run Scipts in the Terminal by specifying the full path of this ./mycript.shscript for example, for scripts named "myscript.sh"

How to run Linux command outside Bash?
To execute the * NIX command, you do not need to run the Bash shell first, instead run the script or launch a program. You can run the command line directly using bash -c, the command can be used for many purposes such as:
Create Desktop shortcuts
  • Run the Linux program directly from the Run tool
  • Call a batch Linux command or PowerShell scripts
For example, you can do the following steps to run the "vi" editor:
  1. Hit "Win" + "R" to run the Run tool
  2. In the Run window, type bash -c "vi"and click OK to run the vi editor

How to run GUI program with Bash?
Bash On Ubuntu does not support GUI software fully compatible, but you can still run some graphing tools with the old VNC tricks. The trick requires "X Server" running on Windows, and Bash On Ubuntu is configured to route the graph to the server.
Here are the setup steps:
  1. Install the X Server application on Windows like Xming

  1. Install the GUI program in Bash using the command apt-get, for example: run   sudo apt-get install vim-gtkto install the Vim background gtk editor
  1. Once installed, run the command export DISPLAY=:0in Bash
Note: You must run this command every time you reopen Bash.
  1.  Now, start the GUI * NIX tool by running its executable name in Bash, for example, execute the command gvimto launch the Vim background editor GTK.
Note: This tip is not yet fully supported for all * NIX based GUIs, so if your favorite software does not work, do not worry and wait for official updates in the future. . Furthermore, the system still crashed when running some GUI tools for the same reason.

Popular and useful Bash commands
Bash On Ubuntu supports many common commands and many other utilities for work as well as scripting. Here are some common commands of Unix and Linux

In a nutshell - a good start
Bash On Ubuntu on Windows 10 proved a new beginning for Microsoft as it eventually offered free and open source software on Windows.
This allows developers to take advantage of the vast open source ecosystem without having to install parallel Linux with Windows or install a virtual machine.
However, NIX applications still can not interact with other Windows software. Hopefully in the future Microsoft will support that, anyway this is still just the launch phase.

No comments:

Post a Comment