In this blog post, we will look at Installing Microsoft PowerShell on Linux OS.
Microsoft released PowerShell scripting language and command-line shell as open source on Aug 18, 2016. It is MIT-licensed open source project hosted on GitHub.
As of now, Alpha version pre-built packages of the open source version are available for following 64 Bit OS:
- Ubuntu 16.04
- Ubuntu 14.04
- CentOS 7
- Red Hat Enterprise Linux 7
- Mac OS X 10.11.
There are also Dockerfiles available in the PowerShell GitHub repo, which enable building and running PowerShell in a container for each Linux distribution Microsoft supports
Microsoft says that support for additional platforms will come soon. Microsoft’s strategy was to first bring .NET to Linux and other non-windows platforms, followed by PowerShell, which is built on top of .NET.
This also paves way for dependent/related tools like Microsoft Operations Management Suite (OMS) and PowerShell Desired State Configuration (DSC) to extend to a greater reach.
Download the Packages from Microsoft’s PowerShell GitHub Repo:
You can go to the PowerShell’s GitHub home, and visit the Releases page to find the packages. Download the relevant one for your operating system:
- Ubuntu 16.04: Download the package ending in “16.04.1_amd64.deb”.
- Ubuntu 14.04: Download the package ending in “14.04.1_amd64.deb”.
- CentOS 7 and Red Hat Enterprise Linux 7: Download the package ending in “el7.centos.x86_64.rpm”.
- Mac: Download the package ending in “.pkg”. [We will not cover Mac in this post as my Mac Pro has gone for repair]
Installing PowerShell on Linux
After downloading the relevant package, launch a terminal window on Linux desktop. You will then need to install the package’s dependencies, and the package itself.
On Ubuntu 16.04 – Run following commands on the terminal:
sudo apt-get install libunwind8 libicu55 sudo dpkg -i <path of the downloaded package/full name of the package with .deb extension>
On Ubuntu 14.04 – Run following commands on the terminal:
sudo apt-get install libunwind8 libicu52 sudo dpkg -i <path of the downloaded package/full name of the package with .deb extension>
On CentOS 7 and RHEL 7 – Run following commands on the terminal:
sudo yum install <path of the downloaded package/full name of the package with .rpm extension>
After following the above steps for your OS, PowerShell would be installed on your system.
You could more simply Install the relevant packages using the GUI on your Linux OS, by clicking the downloaded package. You can see the steps in the series of screenshots from my local Ubuntu 16.04 VM below:
Step 1: Go to the PowerShell’s GitHub repository
Step 2: Locate the relevant PowerShell package for your OS:
Step 3: Download the relevant PowerShell package for your OS (In this case I have downloaded for my Ubuntu 16.04 OS):
Step 4: On Clicking the downloaded PowerShell package, you will be shown the following screen
Step 5: You can type “powershell” on your terminal, and you will be taken to the PowerShell prompt
That’s all very simple to Install and get going.
In case you find this post helpful / useful, or have any doubts / questions, please feel free to comment below.