Windows 10 Ubuntu Bash Thread - Tips and cool stuff! [Build 14316 or higher]

Talderon

New member
Nov 19, 2012
870
0
0
Visit site
[TL;DR] Linux in Windows - Not for everyone, but really cool for Dev's, Engineers, Hobbyists and those that want to learn.

Hey all. I thought I would start a thread on the new BASH shell integration in Windows 10 Insider Preview.

We can get into debates on the validity of this move and the pro's and con's, but I would like that to be in a different thread.

The purpose of this thread is to get people started, teach them how to set it up and also some tips and tricks.

One of the things I have learned by playing with this is it is near having Ubuntu running in tandem with Windows. It has it's own separate sub-system so it is really Linux in look, feel and usage. You have to configure it just like you would with an Ubuntu CLI installation. If you want to use JAVA, the installation of the JRE and JDK is separate from your Windows system. This gives you a LOT of room to do things in a true Linux Bash Shell without having to work around Windows.

Is this for everyone? No. Will most consumers really get the warm-fuzzies from this feature? No. But for someone like me (Sr. DevOps Cloud Platform Engineer) and manages thousands of machines in AWS that are 100% Linux, yeah, I get all giggly when i can open a true bash shell and use my scripts and work in the cloud.

The Linux Subsystem for Windows allows you to run Linux applications directly on Windows. Microsoft has worked with Canonical to offer a full Ubuntu-based Bash shell that runs atop this subsystem. Technically, this isn?t Linux at all. Linux is the underlying operating system kernel, and that isn?t available here. Instead, this allows you to run the Bash shell and the exact same binaries you?d normally run on Ubuntu Linux.

There are some limitations here. This won?t work with server software, and it won?t work with graphical software. It?s intended for developers who want to run Linux command-line utilities on Windows. These applications get access to the Windows file system, but you can?t use Bash commands to automate normal Windows programs, or launch Bash commands from the standard Windows command-line. They get access to the same Windows file system, but that?s it. Not every command-line application will work, either, as this feature is still in BETA.

Ok, let's get started.

How do you activate/install these components.

  1. You MUST be running Windows Insider Preview Build 14316 or higher.
  2. You MUST be running 64 bit Windows 10

As of this post, the build I am running is 14352, so if the instructions differ slightly to what you are seeing, poke around, you're bound to find it!

  • Open the Settings app and head to Update & Security > For Developers
  • Activate the ?Developer Mode? switch here to enable Developer Mode.
  • Open the Control Panel, click ?Programs? (you can type: appwiz.cpl into the search bar and open it that way)
  • Click ?Turn Windows Features On or Off? under Programs and Features
  • Enable the ?Windows Subsystem for Linux (Beta)? option in the list
  • --After you do, you?ll be prompted to reboot your computer. Click ?Restart Now? to reboot your computer and Windows 10 will install the new feature.
  • Open PowerShell
  • Type: bash

This will perform the actual installation of the Linux Subsystem
You will be asked for a Unix User Name and Password, be sure to use something you will remember!! This does not have to be the same as your Windows login, but it can be. Just be sure to remember it.
Once the installation is complete, you may be prompted to reboot your computer again

Locate the "Bash on Ubuntu on Windows" link in your start menu and you will be dropped into your bash shell!

Ok, here are some tips to get things going:

Update your subsystem:

Type: sudo apt-get update
When you are asked for your password, this would be the password you set up during the installation of the subsystem. During the beta period, I would run this weekly to ensure you have the latest and greatest.

If you ever try and run a command and are given a permission denied, just add sudo in front of it and enter your password. Your password will be cached for a short period of time so you will not have to enter it every time unless there are several minutes between sudo commands.

Searching the Repo for Applications:

Search for Available Packages: apt-cache search word (Replace ?word? with a word you want to search package names and descriptions for.)

Example: apt-cache search maildrop
courier-maildrop - Courier mail server - mail delivery agent
getmail4 - mail retriever with support for POP3, IMAP4 and SDPS
maildrop - mail delivery agent with filtering abilities
php-horde-ingo - An email filter rules manager
rdeliver - A fully functioning mail filter with RubyFilter
sensible-mda - Mail Delivery Agent wrapper
spamprobe - Bayesian spam filter


Once you see the package you want to install, use the apt-get command.
When installing applications, you will need to use elevated permissions (sudo)

Example: sudo apt-get install maildrop

This will install the package and all dependencies.

Uninstalling an application is just as easy.

Example: sudo apt-get remove maildrop

This will uninstall the package and all dependencies.

A Few Environmental Catches

Most of what I run in the cloud is CentOS or RHEL. It is a different Linux Distribution Subsystem than Ubuntu (Cent/RH is Fedora based and Ubuntu is Debian based) so the differences are several, but not altogether hard to get used too.

I love using Alias'. for me using 'ls' is annoying and typing 'ls-la' is a pain, so normally I would put m y Alias' in my .bash_profile in my home directory. With this Ubuntu Subsystem, you have to put them in the '.bash_aliases' file. If it does not exist, create it.

vi .bash_aliases

This will open VI and the .bash_aliases (create when saved)

The alias format is (one per line):

alias <command_alias>="<shell_command>"

Example: alias ls="ls -la"

You will have to reload your environment config again: source ~/.bash_aliases
(I created an alias for this as well: alias pload="source ~/.bash_aliases")

Now, whenever you type 'ls' you will actually be running 'ls -la'

Okay, I hope this will get things rolling and get people into this Bash on Windows!!!
 

Talderon

New member
Nov 19, 2012
870
0
0
Visit site
Oh yeah, I forgot to mention in this thread that you can access all of your drives from the Bash Shell.

All of your drives are mounted in '/mnt/'

Example:

talderon@DESKTOP-I0T18NT:~$ cd /mnt
talderon@DESKTOP-I0T18NT:/mnt$ ls
Code:
total 56
drwxr-xr-x 2 root root 0 Dec 31  1969 .
drwxrwxr-x 2 root root 0 Dec 31  1969 ..
drwxrwxrwx 2 root root 0 May 31 19:44 c
drwxrwxrwx 2 root root 0 May 31 19:44 d
drwxrwxrwx 2 root root 0 May 31 19:44 e
drwxrwxrwx 2 root root 0 May 31 19:44 f
drwxrwxrwx 2 root root 0 May 31 19:44 g
drwxrwxrwx 2 root root 0 May 31 19:44 h
drwxrwxrwx 2 root root 0 May 29 15:24 i
drwxrwxrwx 2 root root 0 May 31 19:44 j
dchristilaw@DESKTOP-I0T18NT:/mnt$ cd d
dchristilaw@DESKTOP-I0T18NT:/mnt/d$ ls
Code:
total 96
drwxrwxrwx 2 root root 0 May 31 19:44 .
drwxr-xr-x 2 root root 0 Dec 31  1969 ..
drwxrwxrwx 2 root root 0 May 31 19:43 31e0ddb67f2b3b7e532f
drwxrwxrwx 2 root root 0 May 29 23:22 talderon
dr-xr-xr-x 2 root root 0 Jun  2 00:47 MapData
drwxrwxrwx 2 root root 0 May 30 01:06 msdownld.tmp
drwxrwxrwx 2 root root 0 Jun  2 20:11 Program Files (x86)
drwxrwxrwx 2 root root 0 May 29 14:08 $RECYCLE.BIN
drwxrwxrwx 2 root root 0 May 30 00:02 Rotation-05-29-16
dr-xr-xr-x 2 root root 0 May 29 23:49 SoftwareDistribution
d--------- 2 root root 0 May 29 23:21 System Volume Information
drwxrwxrwx 2 root root 0 May 29 23:21 WindowsApps
drwxrwxrwx 2 root root 0 May 29 23:34 WpSystem
 

nivesh d

New member
Jul 5, 2016
1
0
0
Visit site
Is there anyway one can open applications through this bash. I tried to open gedit and gnuplot application windows through this and it didnt work!!
 

wrecklass

New member
Aug 4, 2016
2
0
0
Visit site
With bash for windows can I have ssh
Well, that's a tricky question. First of all, the Windows subsystem for Linux does have the ssh client so you can ssh to remote systems. However, if you are talking about logging into Windows 10 with ssh, that is a different matter. With the Anniversary update they have added an SSHD server, but when you log into your Windows 10 machine via ssh you are not in a Bash shell. Instead you are in the Powershell. I don't think you can start bash over the remote login.

So yes, you can log in to Windows 10 with ssh, but it is not part of the Bash on Windows package. To use sshd from linux shell, you would have to disable the SSH remote proxy services and then install and configure SSHD under Linux. I have not tried this, so I can't say if that works. I just use CYGWIN with SSHD for now to accomplish this with more features than the Windows subsystem for Linux currently has.
 

wrecklass

New member
Aug 4, 2016
2
0
0
Visit site
Is there anyway one can open applications through this bash. I tried to open gedit and gnuplot application windows through this and it didnt work!!
No, this does not work as the Windows subsystem for Linux does not recognize Windows apps and apparently there is no communications between Windows and Linux at this level. I believe there are people working on a work around for this, but for now this is one area where Cygwin provides more functionality than Windows subsystem for Linux.
 

Members online

No members online now.

Forum statistics

Threads
323,197
Messages
2,243,433
Members
428,035
Latest member
jacobss