How to install Microsoft PowerShell on Ubuntu 22.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn how to install Microsoft PowerShell on Ubuntu 22.04.

Introduction to PowerShell

Windows PowerShell is a task-based command-line shell and scripting language designed specifically for system administration. It was born in response to the absolute dominance of Linux in the server environment and to replace the old command prompt.

Thanks to PowerShell, it is possible to interact with other Microsoft products in a better way and to perform automation tasks with them.

It is based on the .NET Framework, and helps professionals to better interact with Windows environments and their tools. So if you’re a server administrator or server support professional, you’re likely to need PowerShell at some point.

Fortunately, we can install it on Linux and specifically on Fedora 35 which is a very popular and well regarded operating system in the community.

Let’s go for it.

Install PowerShell on Ubuntu 22.04

Although PowerShell is not included in the official Ubuntu repositories, the installation process is simple. And the best thing is that we have two options to install it.

Getting PowerShell on Ubuntu using the official repository

Microsoft has a repository dedicated to Ubuntu, so we can not only install it, but also keep it updated. To achieve this, open a terminal and update the system.

sudo apt update
sudo apt upgrade

After this, we will have to add the repository to the system by downloading and installing a package provided by Microsoft.

First, download it:

wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb

And then, install it:

sudo apt install ./packages-microsoft-prod.deb

This way, when you unpack it, the repository will be added to the system.

Then, refresh APT.

sudo apt update

And finally, install Microsoft PowerShell on Ubuntu 22.04 with this command

sudo apt install powershell
Install PowerShell on Ubuntu 22.04
Install PowerShell on Ubuntu 22.04

Then you can use it with the command

pwsh
Using the Microsoft PowerShell
Using the Microsoft PowerShell

Using Snap to install PowerShell

Another, more direct and even faster option is to install PowerShell using snap.

In this case, there is not much of a trick and all you have to do is run

sudo snap install powershell --classic

At the end of the process, you can also run it with

pwsh

And then you can use it without too much trouble.

Conclusion

PowerShell has meant a change in Microsoft’s policies towards Linux, and now we can use it in our system and thus open the possibilities of integration.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook