How To Install PowerShell On Linux

Earlier this month Microsoft announced that PowerShell had been open sourced and would be available for use in Linux. As a result of this, PowerShell is now available for Ubuntu 14.04 and 16.04, CentOS/RHEL 7, and macOS 10.11.

If your first thought is along the lines of “who would use this abomination?”, then you’re in good company. My best thought at who this is targeted towards is the Windows system administrator that needs to be able to manage Linux systems as they are likely already quite familiar with PowerShell and perhaps unwilling to change.

Personally I’d look at using a tool such as Puppet for managing systems running various operating systems, however here’s how you can install PowerShell in Linux should you want to take this path.

Install PowerShell In Linux

Note: Please keep in mind that at the time of writing, PowerShell on Linux is in the alpha stages and should therefore only be used for testing and not in a production environment.

PowerShell packages for all supported operating systems can be downloaded from the PowerShell GitHub page.

Under the Downloads section you should see the various packages that are available for download and installation.

Install PowerShell On CentOS 7

Here we simply download the latest RPM package file from the GitHub page with the ‘wget’ command, then install it as root with ‘yum’.

[[email protected] ~]# wget
[[email protected] ~]# yum install powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm -y

In my case, I’m downloading v6.0.0-alpha.9 which is the latest version at the time of writing, make sure you get the latest version rather than copying the above command exactly.

Install PowerShell On Ubuntu 14.04

There are a couple of dependencies when installing in Ubuntu which must first be installed.

[email protected]:~# apt-get install libunwind8 libicu52 -y

Once complete, download the latest .deb file for Ubuntu 14.04 and install it with the ‘dpkg’ command.

[email protected]:~# wget
[email protected]:~# dpkg -i powershell_6.0.0-alpha.9-1ubuntu1.14.04.1_amd64.deb

Install PowerShell On Ubuntu 16.04

The process for the newer Ubuntu 16.04 is slightly different, as we must instead install the libicu55 package rather than libicu52.

[email protected]:~# apt-get install libunwind8 libicu55 -y

Once the dependencies have been installed, the .deb file can be downloaded with ‘wget’ and installed with ‘dpkg’.

[email protected]:~# wget
[email protected]:~# dpkg -i powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb

Using PowerShell On Linux

Once the PowerShell package has been installed, you can start using PowerShell by simply running the ‘powershell’ command as shown below.

[[email protected] ~]# powershell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS /root>

From here you can run your PowerShell commands. You can type ‘help’ for additional information, and tab complete is also available to help you find commands.

It appears that you can also combine the use of bash commands with PowerShell, as demonstrated below with the use of the grep command.

PS /root> Get-Process | grep httpd
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
      0       0        0          1      0.060  44424 424 httpd

To exit PowerShell, simply type the ‘exit’ command.

PS /root> exit
[[email protected] ~]#


While I will personally be unlikely to make use of PowerShell on Linux or macOS as I prefer bash, it will undoubtedly make life easier for a number of Windows users that already know how to use PowerShell commands and syntax. Perhaps by giving them their first taste of Linux they may even see the light and learn further about it and get into bash or some other shell!

Regardless it’s nice to see Microsoft providing open source options for other operating systems, even if they appear strange at first glance.

“If Microsoft ever does applications for Linux it means I’ve won.” – Linus Torvalds

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>