- Scalability and availability for Azure Web Apps - Wed, Jun 28 2017
- Managing Azure Virtual Machine scale sets - Wed, May 31 2017
- Azure virtual machine scale sets - Mon, May 8 2017
Some of such cool things are native Linux tasks, which we are now able to test on Windows, and some things are present just for fun. In general, however, I believe that Bash is a new way for Windows Administrators to extend their abilities and is a great addition for Linux Administrators with regard to their developer environments.
Monitor system resources and performance
It’s crucial for system administrators to monitor system resources and performance on a daily basis. Most of the important monitoring and debug commands on the native Linux distros also work on Windows 10 Bash.
The top command is a good way to see the running processes in an ordered list and get an overview of the load on your computer. It’s a dynamic output and updates continuously.
LSOF shows open files, with some additional details such as User, Size, Type, etc.
You can also use HTOP, which is a much more advanced process monitoring tool. It’s not installed by default on Windows 10 Bash, but you can simply install it using the following command:
sudo apt-get install htop
Also, with the simple command free, you can check how much memory you have available.
You can also run the following one-liner with the popular Linux command awk to see the available physical memory in KB:
Using native SSH
By executing the ssh command, you are able to start to play with SSH in Windows Bash.
In the example below, I established an SSH connection to my Azure Ubuntu server from Windows 10 Bash:
Python is my second favorite scripting language (my absolute favorite is PowerShell). It’s very easy to transfer your PowerShell knowledge into Python as its syntax and logic are quite similar to that of PowerShell.
Python v2 and v3 come pre-installed with Ubuntu, which means that the Bash on your Windows 10 Insider build also has Python installed by default.
In Python, you can begin coding right away by simply typing “Python” or “Python3”.
One way to install and manage packages in Python is to use PIP (Preferred Installer Program). To install PIP with the dev tools, run the below command on your Bash:
And there you have it. You now have a ready-to-go Python environment on your Windows 10 computer. Are you interested in game development? Why not install the PYGame module? Here is a list of useful modules you can start with.
Machine learning libraries
Well, there are a bunch of open source projects or efficient tools for data mining and data analysis but Python is probably one of the most versatile languages out there for machine learning. Moreover, Python and most of its machine learning libraries are free.
Scikit-learn is a free library for machine learning the Python language. It features various classification, regression, and clustering algorithms.
You can follow the instructions from the guide here to install it on your Windows 10 Bash, just as you would if you were using a Linux machine.
Installing the required packages for SciPy is the first step. SciPy is a Python-based ecosystem of open source software for mathematics, science, and engineering.
You can use PIP to install Scikit-learn:
You are now ready to go with your machine learning project on your Windows 10.
Scikit-learn has some built-in datasets for the classification and regression of supervised learning problems.
The following code sample will load iris and digits pre-built datasets:
Digits.data shows the features that can be used to classify the digits samples.
I’m not a machine learning guru but it’s pretty awesome to be able to use open source libraries and machine learning packages without leaving your Windows 10 machine.
Node.js is a popular open source runtime environment for developing web applications which can run on a wide variety of endpoints and devices.
Node.js is also installed on Windows 10 Bash by default. I just updated it using the apt-get upgrade -y nodejs command.
Let’s check the version number and see where our node is installed:
You can give it a try using a basic console.log command under node:
Node Package Manager
NPM is the package manager that developers use to share and reuse code. This reusable code comes in packages. You can search for packages in online repositories, use the command line to install them, and then do version management. In that way, you can also easily install Node.js applications.
Node.js comes with NPM installed, so you don’t need to worry about installing it separately on Windows 10.
Let’s check again where it’s installed and what version we have:
Listing of current packages on Bash (I just installed the node-PowerShell package):
You can search for packages online using the NPM search command. A local index will be built when you first run the command.
Azure CLI NPM Package
So now we have Node.js, NPM, and an Ubuntu Bash. Why don’t we use Azure cross platform CLI tools to interact with our Azure resources?
You can easily install the Azure-CLI from the NPM repository, which requires Node.js and NPM as prerequisites. In our case, we have everything in place on our Windows 10 Bash! Let’s start with the installation of the Azure CLI NPM package.
The error message "node: No such file or directory" is a known issue. To resolve this error, we need to create a symbolic link to /usr/bin/node by running the command below:
sudo ln -s /usr/bin/nodejs /usr/bin/node
Now we are ready to go. Type “Azure”.
We can use the Azure CLI to connect to our Azure Subscription.
The Azure Login command will create an authentication code so that you can use it on http://aka.ms/devicelogin.
And I’m now connected to my subscription in Bash.
You can use two different command modes with the Azure CLI: Service Management and Resource Manager. Use the following command to set the command mode to ARM:
The next command lists my accounts:
For other available Azure CLI commands, please read this:
Azure CLI commands in Azure Service Management (ASM) mode
Azure CLI commands in Resource Manager mode
Using VIM editor and finding the Easter egg
VIM is the enhanced version of vi, which is a popular text editor in Linux. There are several modes of VIM such as Command Mode, Insert Mode, and Visual Mode.
VIM is already installed on Windows 10 Bash and it supports all modes. You can also the use apt-get command to check whether you are using the latest version.
Type “VIM” to start, and play with it.
Here are the basic commands you can start with:
h — moves left
l — moves right
j — moves down
k — moves up
:help — open help
:q — quit Vim
:wq — save and quit Vim
:q! — quit without saving
:w — saves the current file
There is also an Easter egg in VIM help file. Type “:help 42” to access a special help menu (a quote from Douglas Adams, the author of The Hitchhiker's Guide to the Galaxy).
By default, the alias command shows a list of aliases in Bash that are defined for the current user.
To create your own alias, you can use following command:
To clear my screen, I simply configured “c”.
In the next post in this series, I will show you a few fun things that you can do with the Windows 10 Bash.
Want to write for 4sysops? We are looking for new authors.
While Bash in Windows 10 is a neat idea, MobaXterm has been available for several years and works on all modern versions of Windows. MobaXterm is a single executable that provides Bash, SSH, PowerShell, X-Windows, RDP, SFTP, Serial, etc, etc, etc. The personal version is free for non-corporate use. A paid-Professional version is also available for corporate use are a very reasonable cost.
Function keys not working.. What can I do?