Microsoft's PowerShell for Linux
New Shell on the Beach
Microsoft released its PowerShell under a free license in August 2016 and ported the tool to Linux and Mac OS. Is PowerShell for Linux a mere marketing ploy or a real contender that can compete with native Linux shells?
Microsoft has done its part to perpetuate its image as the bogeyman of the Open Source movement. Who could forget the advertising campaign in which Microsoft gave penguins the mutant heads of other animals – such as a frog with antlers, implying that an open operating system with parts from different places is somehow unnatural? Or when former Microsoft CEO Steve Ballmer called Linux a "cancer" [1]?
For a few years now, however, Microsoft has been toning down its rhetoric and pursuing something more like an appeasement policy, with vague statements about whether Windows would one day have an open license; Microsoft even perplexed the community at one point when it announced it was about to develop its own Linux for its cloud [2].
Recent signs, however, point to genuine improvement in the Microsoft-Linux relationship. A photo from LinuxCon 2016, which made the rounds on social media, showed Linux creator Linus Torvalds standing by the Microsoft booth, comfortably sipping a cup of coffee [3]. In 2000, Torvalds made an April Fools joke out of naming Microsoft as a partner for Linux development work. What once was a joke is now reality, and the biggest evidence of Microsoft's commitment to Open Source is the recent release of the Windows PowerShell command environment under a free license, along with the announcement that Microsoft was porting PowerShell to Linux and Mac OS.
What and Why?
The first major PowerShell release appeared in 2007. The idea of PowerShell is to create an alternative to the cmd.exe
command-line tool, which was included on Windows systems until recently. The cmd.exe
environment had very limited functionality.
I should also note, for reasons of fairness, that Microsoft considers cmd.exe
more of a relic from the past than an up-to-date tool for admins. Microsoft introduced PowerShell to provide a tool for the power user. Over the years, PowerShell has gained many fans and indeed acquired prestige.
The goal of PowerShell is to provide a command-line environment that allows the user to execute commands without going through a GUI. Does Microsoft believe it is offering Linux users added value? What is behind the release of PowerShell for Linux?
The fact that Microsoft wants to promote its .NET framework is likely an important reason for the company's venture into PowerShell for Linux. Part of porting PowerShell to Linux was creating a core .NET platform for the Linux environment. With that platform providing the basis, putting PowerShell on Linux became a comparatively simple exercise.
However, Microsoft is also looking to the cloud. The popularity of Linux instances running in the cloud does not escape Microsoft's watchful eye. Redmond knows its cloud environment will have to support Linux, and by maintaining their own tools for administering both Linux and Windows systems, they can better maintain their position as a player in the server market. The combination of the PowerShell tools, DSC, and the Operations Management Suite makes it possible for you to administrate your own instances on Linux in Microsoft's Azure public cloud.
Basic Features
Under the hood, PowerShell is based on Microsoft's .NET framework. It mixes different methods: On the one hand, PowerShell allows you to execute simple command-line commands, just as admins would be familiar with from Linux. Different commands can also be combined to produce typical shell scripts. PowerShell controls central shell functions on Linux as well, including the ability to redirect the output of a program to another by piping. On the other hand, PowerShell follows an object-oriented approach: You can define methods and objects that then use the methods.
The central pivot points for working with PowerShell are the commandlets. In PowerShell speak, a cmdlet is a .NET class that performs a specified task after launching. Cmdlets are essentially the actual commands, which can be bundled together in the form of scripts or even binaries. Microsoft has invested a lot of work in equipping PowerShell with many useful cmdlets. Straight after installation, there are many commands available, such as for deleting files or directories, creating folders, or displaying the folder contents (Figure 1).
According to the PowerShell standard, cmdlets must have a unique name consisting of a verb and object. As a result, the cmdlet for deleting folders or files is officially remove-item
. Another example: The cmdlet for downloads from the Internet is invoke-WebRequest
; if you are accustomed to Linux, an alternative for invoke-WebRequest
would be wget
or curl
.
To make the transition to PowerShell easier for experienced Linux admins, Microsoft alias-mapped common Linux commands to PowerShell cmdlets. After complaints from the user base, however, Microsoft rejected this approach, because it ultimately prevents users from executing the real command-line programs, such as ls
or cd
.
Installation on Linux
Microsoft is clearly keen to keep entry barriers as low as possible for PowerShell on Linux. The company is making the source code for PowerShell Version 6 available to the public on GitHub, but it is also offering a package version for the major Linux distributions. So it is very easy to get started, for instance, on Ubuntu 16.04 [4].
After the installation of the libunwind8
and libicu55
packages, you can install the PowerShell package with dpkg -i
(Figure 2).
The service would be even better if PowerShell came from a real package repository with signed release files, though this may still be too great an effort for Microsoft. Because packages for various RPM-based distributions are also available from the provider, Microsoft would have to convert the repository for several package systems. Even without their own repository, it works: Good job! So all kinds of others software projects can take a big page out of Microsoft's book.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.