Software

How to install PowerShell on Linux with snap

Microsoft has created a snap version of Windows PowerShell--so now you can tap into that power and efficiency on your Linux platform. Here's how it works.

linuxcommandhero.jpg
Image: Jack Wallen

In a turn that may or may not surprise you (depending on how you've been viewing the whole "Microsoft loves Linux" era), the company that brought us Windows has created a snap version of PowerShell. Most IT pros know what PowerShell is and how to use it. For those who might be new to this idea, PowerShell is a task automation and configuration management framework that consists of a command-line shell and associated scripting language. It's powerful, and for many IT admins, it's a requirement for efficiently working with the command line in Windows.

And now, you can enjoy that same power and efficiency from within your Linux environment.

Let the "Microsoft loves Linux" parade keep rolling.

I'm going to walk you through the process of installing PowerShell on Ubuntu. I'll be using Elementary OS, although you could just as easily install this on any Debian-based distribution (including Ubuntu Desktops or Servers). I'm going to assume you at least have a Linux distribution available that supports snap packages (which would include most distributions, Debian-based or not).

SEE: Windows administrator's PowerShell script kit (Tech Pro Research)

Snap

Out of the box, Elementary OS doesn't included snapd. If you are using a Debian-based platform that doesn't include snapd, install it with the command:

sudo apt-get install snapd

If you're on a distribution based on Red Hat, the installation command would be:

sudo yum install snapd

Or

sudo dnf install snapd

Once the installation of snapd completes, you should have everything you need to install the PowerShell snap package.

Installing PowerShell

This powerful tool can be installed with the single command:

sudo snap install powershell --classic

Do note the addition of the classic option. This means that the snap package will be installed with the security confinement disabled. In a nutshell, the snap package will have full access to the rest of the system. When snap packages are installed with security confinement enabled, they are installed in a read-only environment.

The installation shouldn't take long (less than a minute). When the install completes, issue the command pwsh and you will find yourself in the Microsoft PowerShell prompt (Figure A).

Figure A

Figure A

The PowerShell tool is ready to serve you.

Of course, using PowerShell is quite different from using the standard Linux command line. If you know this tool, you can now start working with it on your Linux platform. For those who are new to PowerShell, I suggest you first give PowerShell: The Smart Person's Guide a read. After that, check out all the information about the tool on TechRepublic.

SEE: 20 PowerShell cmdlets you can use instead of CMD commands (free TechRepublic PDF)

Welcome to a new world order

And you thought the Linux platform couldn't get any more powerful and useful. Now that you can make use of a tool you've probably been using on Windows for a long time, Linux offers even more power. Welcome to a new world order.


Favorite cmdlets?

What cmdlets do you rely on to manage your day-to-day admin tasks? Share your advice and tips with fellow TechRepublic members.

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox