How to Install PowerShell on Ubuntu 22.04 / Ubuntu 20.04
PowerShell is a task automation and configuration program consisting of a command-line shell and scripting language. It was initially developed as a Windows component known as Windows PowerShell. Then, later, in 2016, with the introduction of PowerShell Core, it was made open-source and cross-platform.
PowerShell is available for Windows, Linux, and macOS.
Here, we will see how to install PowerShell on Ubuntu 22.04 / Ubuntu 20.04.
Install PowerShell on Ubuntu 22.04 / 20.04
You can install PowerShell on Ubuntu using snap (the most straightforward way) or the Microsoft repository.
1. Install PowerShell Using Snap
Installing PowerShell using snap sudo apt install -y snap
is the quickest way to install it on Ubuntu.
Use the snap
command to install PowerShell.
sudo snap install powershell --classic
snap install powershell-preview --classic
command.After the installation is complete, validate the PowerShell installation using the below command.
sudo snap list powershell
Output:
Name Version Rev Tracking Publisher Notes powershell 7.2.2 202 latest/stable microsoft-powershell✓ classic
2. Install PowerShell Using Official Repository
Microsoft offers a dedicated repository for the PowerShell package for Linux operating systems. We will now set up the Microsoft repository and install PowerShell.
When writing this post, the Microsoft PowerShell repository doesn’t have the PowerShell package for Ubuntu 22.04. So, I recommend installing PowerShell from the Snap store on Ubuntu 22.04.
The below steps may work in the coming days.
First, download the Microsoft repository configuration package.
# Ubuntu 22.04 wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb # Ubuntu 20.04 wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Then, install the Microsoft repository configuration package.
sudo dpkg -i packages-microsoft-prod.deb
After adding the Microsoft repository for PowerShell, update the repository index with the below command.
sudo apt update
Finally, install the PowerShell package using the apt
command.
sudo apt install -y powershell
sudo apt install -y powershell-preview
command.Launch PowerShell
You can start the PowerShell on Ubuntu by going to Activities >> search for PowerShell or with the pwsh
command. PowerShell preview with pwsh-preview
command.

Conclusion
That’s all. I hope you have learned how to install PowerShell on Ubuntu 22.04 / Ubuntu 20.04.