Powershell

How to install PowerShell on Ubuntu 22.04

PowerShell is a command-line utility to automate various tasks or to build tools using its scripting language support. PowerShell has built-in support available for the Windows Operating system. However, it can be installed on various Linux distributions due to its open-source cross-platform support.

Ubuntu is the widely used Debian based Linux distribution. Ubuntu has recently released its Long-Term Support 22.04 with a code name “Jammy Jellyfish”.

This article lists down possible methods to install PowerShell on Ubuntu 22.04 with the following learning outcomes:

How to install PowerShell on Ubuntu 22.04

Ubuntu 22.04 has its own command line terminal with advanced support for Network/System administrators. However, PowerShell can be used as a secondary terminal on Ubuntu 22.04. The following possible methods can be used to install PowerShell on Ubuntu 22.04.

How to install PowerShell on Ubuntu 22.04 from snap

The snap package manager provides a command line and a GUI store to get applications/programs on Ubuntu 22.04.

Step 1: Firstly, install the snap package manager’s service on your system as follows:

$ sudo apt install snap snapd

We already have the latest version of the snapd.

Step 2: Now, makes use of the below-mentioned command to install PowerShell on Ubuntu:

$ sudo snap install powershell --classic

Once it is installed, you can launch the PowerShell terminal by using the following keywords in Ubuntu’s terminal:

pwsh

It is observed that the PowerShell’s session is started.

How to install PowerShell from the Ubuntu 22.04 repository

Ubuntu has not yet provided support for PowerShell in its official repository. However, the PowerShell repository can be installed on Ubuntu 22.04.

Step 1: First, download the “.deb” package of PowerShell’s repository for Ubuntu via the following command:

$ wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

After downloading the “.deb” file, install it by issuing the below-mentioned command:

$ sudo dpkg -i packages-microsoft-prod.deb

Step 2: Update the core libraries of Ubuntu 22.04 as follows:

$ sudo apt update

Once the update is performed and the PowerShell repository is acknowledged by your system. Install PowerShell as follows:

$ sudo apt install powershell

The output states that the installation has been completed successfully which states the PowerShell is now installed on Ubuntu 22.04.

How to remove PowerShell from Ubuntu 22.04

PowerShell can be used as a secondary terminal on your Ubuntu 22.04. It can be removed from Ubuntu 22.04 by using one of the following commands.

If PowerShell is installed using the snap package manager, then you can remove/uninstall it by issuing the following command:

$ sudo snap remove powershell

If PowerShell is installed by adding its repository, then it can be removed/uninstalled from Ubuntu 22.04 as follows:

$ sudo apt autoremove --purge powershell

Conclusion

PowerShell can be installed on Ubuntu 22.04 from the snap package manager or from the PowerShell’s repository. You have learned both methods to get PowerShell on Ubuntu 22.04. PowerShell is a multipurpose tool for automating several tasks on a computing machine or to develop any tools using its scripting language support. Although PowerShell is an open-source, Ubuntu has not yet added it to its official repository. However, we have provided multiple alternative ways to get PowerShell on Ubuntu 22.04.

About the author

Adnan Shabbir