{"id":80125,"date":"2016-09-28T00:01:11","date_gmt":"2016-09-28T07:01:11","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=80125"},"modified":"2019-02-18T09:10:27","modified_gmt":"2019-02-18T16:10:27","slug":"part-1-install-bash-on-windows-10-omi-cim-server-and-dsc-for-linux","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/part-1-install-bash-on-windows-10-omi-cim-server-and-dsc-for-linux\/","title":{"rendered":"Part 1 \u2013 Install Bash on Windows 10, OMI CIM Server, and DSC for Linux"},"content":{"rendered":"<p><strong>Summary<\/strong>: Learn about the\u00a0<span>Windows Subsystem for Linux that runs on top of Windows 10.<\/span><\/p>\n<p>Today we have a guest article written by Stefan Roth. Take it away Stefan \u2026<\/p>\n<p>Hi, my name is Stefan Roth, and I am a Cloud and Datacenter MVP. In a couple of posts, I would like to show you how cool it is that Microsoft is touching the Linux world. Myself, I am a 100% Microsoft fan, but, as you can read all over the Internet\u2026Microsoft loves Linux. This is not just a one-night stand. Microsoft is really serious about Linux support in all cloud scenarios (private, public, and hybrid). Therefore, we start with something really cool.<\/p>\n<p>I will start a three-part series that touches a few parts of the Linux direction that\u00a0Microsoft is taking. My first post gives you an overview of Bash on Windows 10 by using Secure Shell (SSH). We&#8217;ll\u00a0run a script that installs the prerequisites and sets up a desired state configuration (DSC) environment. The second post will show you how to install .NET Core and PowerShell on Linux by using DSC. The last part will use Azure Automation DSC and the Operations Management Suite injection API for some fun.<\/p>\n<h2>The anniversary update<\/h2>\n<p>Microsoft released the <a target=\"_blank\" href=\"https:\/\/blogs.windows.com\/windowsexperience\/2016\/08\/02\/how-to-get-the-windows-10-anniversary-update\/#VBAb1S3wJU43XwPU.97\">Windows 10 Anniversary Update on August 2nd<\/a>. One awesome new feature is the Windows Subsystem for Linux (WSL) that runs on top of Windows 10. What does that mean? This subsystem allows you to run native Linux binaries on Windows. If you remember back to Windows NT, there was already a POSIX subsystem available for Unix-based applications. Because the Windows NT kernel was designed to run such subsystems, Microsoft could use this architecture and build a subsystem for Linux. Exactly how this works\u00a0is explained in the <a target=\"_blank\" href=\"https:\/\/blogs.msdn.microsoft.com\/wsl\/2016\/04\/22\/windows-subsystem-for-linux-overview\/\">Windows Subsystem for Linux Overview<\/a> blog post.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-1.png\" alt=\"Diagram of the Windows Subsystem for Linux\" width=\"615\" height=\"284\" class=\"alignnone size-full wp-image-80135\" \/><\/a><\/p>\n<p>Why should we care at all? Good question. I think there is a short-term goal and a long-term goal. If you watched <a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/powershell-is-open-sourced-and-is-available-on-linux\/\">Technical Fellow Jeffrey Snover announcing PowerShell on Linux and Open Sourced<\/a> , Jeffrey mentioned a vision to manage any system from any operating system by using Windows PowerShell. One short-term goal is for developers to have a Linux environment available on Windows as also a \u201cnative\u201d way to use SSH to connect and manage native Linux systems, which has been requested for years. <a href=\"http:\/\/www.hanselman.com\/blog\/VIDEOHowToRunLinuxAndBashOnWindows10AnniversaryUpdate.aspx\">Scott Hanselmann has released a nice video on his blog<\/a>, which shows what you can do with Bash and explains some more details.<\/p>\n<h2>Install Bash on Windows<\/h2>\n<p>First, let\u2019s install Bash on Windows 10. Make sure that you have the latest Windows 10 Anniversary 64-bit edition and that you have <strong>Developer Mode<\/strong> enabled. Open the <strong>Settings<\/strong> app and go to <strong>Update &amp; security<\/strong> &gt; <strong>For developers<\/strong>. Select <strong>Developer mode<\/strong> to enable Developer Mode.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-2.png\" alt=\"The &quot;Developer mode&quot; option in &quot;Settings&quot;\" width=\"652\" height=\"516\" class=\"alignnone size-full wp-image-80145\" \/><\/a><\/p>\n<p>Next, use <strong>Turn Windows features on or off<\/strong> to turn on <strong>Windows Subsystem for Linux (Beta)<\/strong>, reboot, and everything is done.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-3.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-3.png\" alt=\"Selection of &quot;Windows Subsystem for Linux (Beta)&quot; in the &quot;Turn Windows features on or off to turn on&quot; dialog box \" width=\"444\" height=\"394\" class=\"alignnone size-full wp-image-80155\" \/><\/a><\/p>\n<p>Type <strong>Bash<\/strong> in the <strong>Run<\/strong> Window, and follow the instructions to complete the setup. Now you are a proud owner of an Ubuntu Bash on Windows 10 that\u2019s waiting for input.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-4.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-4.png\" alt=\"Completed installation of Ubuntu Bash on Windows 10\" width=\"373\" height=\"100\" class=\"alignnone size-full wp-image-80165\" \/><\/a><\/p>\n<p>I have a CentOS 7 x64 Linux system called <em>centos<\/em> installed on my local Hyper-V server. Now let\u2019s connect from your Windows 10 Bash to the CentOS server system by using SSH.<\/p>\n<p>Type within Bash:<\/p>\n<p style=\"padding-left: 30px\"><code>ssh [IP OF YOUR SERVER] -l root<\/code><\/p>\n<p>Enter your password when prompted.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-5.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-5.png\" alt=\"Using SSH to connect to your server\" width=\"546\" height=\"112\" class=\"alignnone size-full wp-image-80185\" \/><\/a><\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>: If you receive a response like this, just confirm by typing yes.<\/p>\n<p style=\"padding-left: 60px\"><em>The authenticity of host &#8216;192.168.32.18 (192.168.32.18)&#8217; can&#8217;t be established. ECDSA key fingerprint is 26:b6:fb:b1:de:76:b0:2e:47:68:0b:94:32:00:c9:08. Are you sure you want to continue connecting (yes\/no)?<\/em><\/p>\n<p>Now you are authenticated as root (root = administrator permission) to the remote system via SSH. If you get an error, check on your Linux server locally to determine if the sshd (SSH daemon) is running by typing:<\/p>\n<p style=\"padding-left: 30px\"><code>service sshd status<\/code><\/p>\n<p>You should get an output as shown in the following screenshot.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-6.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-6.png\" alt=\"Result of &quot;service sshd status&quot; command\" width=\"647\" height=\"352\" class=\"alignnone wp-image-80175 size-full\" \/><\/a><\/p>\n<h2>Install the prerequisites<\/h2>\n<p>Next, we are going to run a little shell script to download all prerequisites and source for the OMI CIM server and the DSC packages. After successful download, we\u2019ll install the rpm packages (Package Manager for Red Hat).<\/p>\n<p>First, to create the script file, go to \/root\/Downloads:<\/p>\n<ol>\n<li><em><\/em>Type <code>vi install.sh<\/code> to\u00a0launch an empty file called install.sh.<\/li>\n<li>Type <code>i<\/code> to\u00a0insert text.<\/li>\n<li>Paste the script\u00a0that follows these steps.<\/li>\n<li>Type <strong>Esc<\/strong> key\u00a0to\u00a0change vi editor mode.<\/li>\n<li>Type <code>:<\/code>.<\/li>\n<li>Type <code>wq!<\/code> to\u00a0write and quit.<\/li>\n<\/ol>\n<p>It should look like this\u2026<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-7.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-7.png\" alt=\"Screenshot of pasted script\" width=\"611\" height=\"342\" class=\"alignnone size-full wp-image-80195\" \/><\/a><\/p>\n<p><strong>Shell script<\/strong>:<\/p>\n<p><code>#####################################################################################<\/code><\/p>\n<p><code>#! \/bin\/sh\n# Get prerequisites for OMI CIM server and DSC\n# Install the Development Tools\n# Get groups by running =&gt; yum groupinstall\nyum -y groupinstall 'Development Tools'<\/code><\/p>\n<p><code># Install python and header files\nyum -y install python\nyum -y install python-devel<\/code><\/p>\n<p><code># Install authentication modules\nyum -y install pam-devel<\/code><\/p>\n<p><code># Install openssl\nyum -y install openssl-devel<\/code><\/p>\n<p><code># Change to the Downloads directory\ncd \/root\/Downloads<\/code><\/p>\n<p><code># Download the OMI CIM server package\nwget https:\/\/github.com\/Microsoft\/omi\/releases\/download\/v1.1.0-0\/omi-1.1.0.ssl_100.x64.rpm<\/code><\/p>\n<p><code># Download the DSC for Linux package\nwget https:\/\/github.com\/Microsoft\/PowerShell-DSC-for-Linux\/releases\/download\/v1.1.1-294\/dsc-1.1.1-294.ssl_100.x64.rpm<\/code><\/p>\n<p><code># Run rpm package manager for the OMI CIM server package\nsudo rpm -Uvh omi-1.1.0.ssl_100.x64.rpm<\/code><\/p>\n<p><code># Run rpm package manager for the DSC package\nsudo rpm -Uvh dsc-1.1.1-294.ssl_100.x64.rpm<\/code>\n<code>###############################################################################<\/code><\/p>\n<p>Next, to set the permission to the script as executable, type:<\/p>\n<p style=\"padding-left: 30px\"><code>chmod +x install.sh<\/code><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-8.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-8.png\" alt=\"Result of &quot;chmod +x install.sh&quot;\" width=\"405\" height=\"156\" class=\"alignnone size-full wp-image-80205\" \/><\/a><\/p>\n<p>Finally, execute the script. The install process will kick off, and you will see the installation.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-9.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-9.png\" alt=\"Result of installation\" width=\"609\" height=\"341\" class=\"alignnone size-full wp-image-80215\" \/><\/a><\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>: If you get an error like<em> \u201c\u2026Another app is currently holding the yum lock\u201d<\/em>, the yum installer is running in the background. To temporarily prevent the database lock, use the following command to stop the daemon.<\/p>\n<p>Stop yum installer<\/p>\n<p style=\"padding-left: 30px\"><code>service packagekit stop<\/code><\/p>\n<p>Run the script again .\/install.sh. If everything worked, you should have a prompt again and run the next command to see the status of the OMI CIM server.<\/p>\n<p>OMI CIM server status<\/p>\n<p style=\"padding-left: 30px\"><code>service omid status<\/code><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-10.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-28-16-10.png\" alt=\"Result of the &quot;service omid status&quot; command\" width=\"612\" height=\"196\" class=\"alignnone size-full wp-image-80225\" \/><\/a><\/p>\n<p>At this point, OMI CIM server and DSC Linux components are installed &#8211; up and running.<\/p>\n<h2>Testing it<\/h2>\n<p>If you want to explore your installation, there are few commands which might help you to troubleshoot OMI CIM server and DSC.<\/p>\n<p><strong>OMI Server<\/strong><\/p>\n<p>Show OMI server version:<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/omi\/bin\/omiserver -v<\/code><\/p>\n<p>Show OMI server help:<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/omi\/bin\/omiserver -h<\/code><\/p>\n<p>Shows the OMI server configuration file<\/p>\n<p style=\"padding-left: 30px\"><code>vi \/etc\/opt\/omi\/conf\/omiserver.conf<\/code><\/p>\n<p>Shows the OMI server log file<\/p>\n<p style=\"padding-left: 30px\"><code>vi \/var\/opt\/omi\/log\/omiserver.log<\/code><\/p>\n<p><strong>DSC<\/strong><\/p>\n<p>Get DSC configuration<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/GetDscConfiguration.py<\/code><\/p>\n<p>Get LCM configuration<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/GetDscLocalConfigurationManager.py<\/code><\/p>\n<p>Install a DSC custom module<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/InstallModule.py \/tmp\/cnx_Resource.zip<\/code><\/p>\n<p>Remove a DSC custom module<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/RemoveModule.py cnx_Resource<\/code><\/p>\n<p>Applies a configuration MOF file to the computer<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/StartDscLocalConfigurationManager.py \u2013configurationmof \/tmp\/localhost.mof<\/code><\/p>\n<p>Applies a Meta Configuration MOF file to the compute<\/p>\n<p style=\"padding-left: 30px\"><code>\/opt\/microsoft\/dsc\/Scripts\/SetDscLocalConfigurationManager.py \u2013configurationmof \/tmp\/localhost.meta.mof<\/code><\/p>\n<p>Shows the DSC log file<\/p>\n<p style=\"padding-left: 30px\"><code>vi \/var\/opt\/omi\/log\/dsc.log<\/code><\/p>\n<h2>Summary<\/h2>\n<p>First, we installed the Windows Subsystem for Linux and used Bash to make a connection to a Linux server by using SSH. From this shell, we ran an installation script to install OMI CIM Server and DSC for Linux.<\/p>\n<p>You might have noticed\u00a0that we never had to leave the Bash window.\u00a0We could manage the Linux server from Windows 10 without logging in to the Linux server console. One small but important goodie I like is that we are also able to copy from Windows and paste to the Bash window as we did tocreate the shell script file.<\/p>\n<p>Thank you, Stefan.<\/p>\n<p>I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. Also check out my <a target=\"_blank\" href=\"https:\/\/blogs.technet.microsoft.com\/msoms\/\">Microsoft Operations Management Suite Blog<\/a>. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn about the\u00a0Windows Subsystem for Linux that runs on top of Windows 10. Today we have a guest article written by Stefan Roth. Take it away Stefan \u2026 Hi, my name is Stefan Roth, and I am a Cloud and Datacenter MVP. In a couple of posts, I would like to show you how [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568,641],"tags":[698,56,3,699,45],"class_list":["post-80125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-windows-powershell","tag-bash","tag-guest-blogger","tag-scripting-guy","tag-stefan-roth","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn about the\u00a0Windows Subsystem for Linux that runs on top of Windows 10. Today we have a guest article written by Stefan Roth. Take it away Stefan \u2026 Hi, my name is Stefan Roth, and I am a Cloud and Datacenter MVP. In a couple of posts, I would like to show you how [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=80125"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80125\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=80125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=80125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=80125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}