How to Install PowerShell on Ubuntu 22.04 or 20.04

PowerShell, developed by Microsoft, is a robust scripting language and automation framework that has carved a niche among Windows administrators. However, its capabilities aren’t confined to Windows alone. Recognizing the growing demand for cross-platform solutions, Microsoft expanded PowerShell’s reach to Linux, including distributions like Ubuntu. For those aiming to install PowerShell on Ubuntu 22.04 Jammy Jellyfish or its older stable release Ubuntu 20.04 Focal Fossa, here’s what sets PowerShell apart:

Key Advantages of PowerShell:

  • Cross-Platform Efficiency: PowerShell’s compatibility with Windows, macOS, and Linux ensures a consistent experience, enabling users to deploy the same scripts and commands across diverse operating systems.
  • Advanced Automation: Renowned for its automation prowess, PowerShell facilitates the crafting of intricate scripts for task automation, system management, and efficient data processing.
  • Seamless Microsoft Integration: For those engaged with Microsoft platforms like Azure, Office 365, or Active Directory, PowerShell offers tailored cmdlets and modules, streamlining interactions.
  • Vibrant Community Backing: A dynamic and expansive PowerShell community offers invaluable resources, from specialized modules to expert guidance, enhancing user efficiency.
  • Ongoing Development: Microsoft’s commitment to PowerShell’s evolution ensures it remains at the forefront of technological advancements.

For those keen on harnessing PowerShell’s capabilities on Ubuntu, the subsequent guide will elucidate the installation process using Microsoft’s official APT repository, ensuring you can access the latest versions and updates.

Install PowerShell on Ubuntu 22.04 or 20.04 via APT

Step 1: Update Ubuntu Before PowerShell Installation

Before installing, update your ystem to ensure all packages are up-to-date. This helps avoid any conflicts during the installation. To do this, open a terminal and execute the following command:

sudo apt update

Once the update is complete, upgrade any outdated packages with the command below:

sudo apt upgrade

Step 2: Install Initial PowerShell Packages on Ubuntu

To install PowerShell, you need to have specific dependencies in place. While most of these packages might already be present on your system, executing the following command ensures they are installed:

sudo apt install dirmngr lsb-release ca-certificates software-properties-common apt-transport-https curl -y

Step 3: Import Microsoft PowerShell APT Repository on Ubuntu

To ensure you always have the most up-to-date version of PowerShell available on your system, you must import the GPG key and the repository. Start by importing the GPG key using the command:

curl -fSsL | sudo gpg --dearmor | sudo tee /usr/share/keyrings/powershell.gpg > /dev/null

Next, import the repository that matches your Ubuntu distribution version.

For Ubuntu 22.04 Jammy JellyFish LTS users, execute the following command:

echo "deb [arch=amd64,armhf,arm64 signed-by=/usr/share/keyrings/powershell.gpg] jammy main" | sudo tee /etc/apt/sources.list.d/powershell.list

For Ubuntu 20.04 Focal Fossa LTS users, execute this command:

echo "deb [arch=amd64,armhf,arm64 signed-by=/usr/share/keyrings/powershell.gpg] focal main" | sudo tee /etc/apt/sources.list.d/powershell.list

Step 4: Update the Packages List After PowerShell PPA Import on Ubuntu

After adding the PowerShell repository, update the packages list by running the following command:

sudo apt update

Step 5: Install PowerShell on Ubuntu 22.04 or 20.04 via APT Command

With everything in place, you can now install PowerShell using the command below:

sudo apt install powershell

Section 2: Verify PowerShell Installation on Ubuntu 22.04 or 20.04

Step 1: Launch PowerShell

With the installation complete, verifying that PowerShell has been correctly installed and is functional on your Ubuntu system is essential. To activate and launch a new PowerShell instance, enter the following command in your terminal:


Upon executing the command, you should see a new PowerShell prompt, indicating that it runs successfully on your system.

Screenshot showcasing a Microsoft PowerShell terminal instance running on Ubuntu 22.04 or 20.04.
A live demonstration of Microsoft PowerShell terminal in action on Ubuntu 22.04 or 20.04.

Now that you have confirmed the successful installation of PowerShell, you can use it to manage your system, run scripts, and execute commands just like you would on a Windows system.

Basic PowerShell Commands on Ubuntu 22.04 or 20.04

Accessing Help with PowerShell on Ubuntu

To access the built-in help system and learn more about PowerShell commands and their usage, use the help command:


This command provides an overview of available cmdlets and basic usage instructions.

Obtain PowerShell Information on Ubuntu

To get detailed information about the PowerShell environment, such as version and runtime, use the Get-Host cmdlet:


List Directory Contents on PowerShell with Ubuntu

To list the contents of a directory, similar to the ls command in Linux, use the dir alias for the Get-ChildItem cmdlet:


Display Command History on PowerShell with Ubuntu

To view the history of previously executed commands in the current PowerShell session, use the Get-History cmdlet:


List Process Information on PowerShell with Ubuntu

To display information about the processes running on your system, use the Get-Process cmdlet:


Exit PowerShell instance on PowerShell with Ubuntu


Additional PowerShell Commands with Ubuntu 22.04 or 20.04

Update PowerShell on Ubuntu 22.04 or 20.04

To check for updates and upgrade all packages, including PowerShell, using the command line, execute the following command. This command ensures your system stays up-to-date:

sudo apt update && sudo apt upgrade

Remove PowerShell From Ubuntu 22.04 or 20.04

If you decide to remove PowerShell from your system, follow these steps:

Use the following command to uninstall PowerShell:

sudo apt remove powershell

Remove the repository by executing the following command:

sudo rm /etc/apt/sources.list.d/powershell.list

For good housekeeping and security, delete the GPG key using the following command:

sudo rm /usr/share/keyrings/powershell.gpg


In conclusion, installing PowerShell on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using Microsoft’s official APT repository provides users with a powerful and versatile command-line interface. Following the steps outlined in this guide, users can seamlessly integrate PowerShell into their Ubuntu environment, expanding their toolkit for efficient system management.

Leave a Comment