Installing PowerShell on Ubuntu

All packages are available on our GitHub releases page. After the package is installed, run pwsh from a terminal. Run pwsh-preview if you installed a preview release. Before installing, check the list of Supported versions below.

Note

PowerShell 7.3 is an in-place upgrade that removes previous versions of PowerShell.

If you need to run PowerShell 7.3 side-by-side with a previous version, reinstall the previous version using the binary archive method.

Ubuntu uses APT (Advanced Package Tool) as a package manager.

Installation via Package Repository

PowerShell for Linux is published to package repositories for easy installation and updates. The URL to the package varies by OS version:

  • Ubuntu 22.04 - https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
  • Ubuntu 20.04 - https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
  • Ubuntu 18.04 - https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

Use the following shell commands to install PowerShell on the target OS.

Note

This only works for supported versions of Ubuntu.

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh

As superuser, register the Microsoft repository once. After registration, you can update PowerShell with sudo apt-get install powershell.

Installation via Direct Download

PowerShell 7.2 introduced a universal package that makes installation easier. Download the installer package from the releases page onto the Ubuntu machine. The link to the current version is:

  • PowerShell 7.3.0 (universal package) for any supported version of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell_7.3.0-1.deb_amd64.deb
  • PowerShell 7.2.7 (universal package) for any supported version of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.2.7/powershell-lts_7.2.7-1.deb_amd64.deb
  • PowerShell 7.0.13
    • Ubuntu 20.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.0.13/powershell-lts_7.0.13-1.ubuntu.20.04_amd64.deb
    • Ubuntu 18.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.0.13/powershell-lts_7.0.13-1.ubuntu.18.04_amd64.deb

Use the following shell commands to install the package. Change the filename of the package to match the version you downloaded.

# Install the downloaded package
sudo dpkg -i powershell-lts_7.3.0-1.deb_amd64.deb

# Resolve missing dependencies and finish the install (if necessary)
sudo apt-get install -f

Note

If the dpkg -i command fails with unmet dependencies, the next command, apt-get install -f resolves these issues then finishes configuring the PowerShell package.

Uninstallation - Ubuntu 16.04

sudo apt-get remove powershell

Support for Arm processors

PowerShell 7.2 and newer supports running on Ubuntu using 32-bit or 64-bit Arm processors. Use the binary archive installation method of installing PowerShell that is described in Alternate ways to install PowerShell on Linux.

PowerShell paths

  • $PSHOME is /opt/microsoft/powershell/7/
  • User profiles are read from ~/.config/powershell/profile.ps1
  • Default profiles are read from $PSHOME/profile.ps1
  • User modules are read from ~/.local/share/powershell/Modules
  • Shared modules are read from /usr/local/share/powershell/Modules
  • Default modules are read from $PSHOME/Modules
  • PSReadLine history is recorded to ~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt

The profiles respect PowerShell's per-host configuration, so the default host-specific profiles exists at Microsoft.PowerShell_profile.ps1 in the same locations.

PowerShell respects the XDG Base Directory Specification on Linux.

Supported versions

The following table is a list of currently supported PowerShell releases and the versions of Ubuntu they are supported on. These versions remain supported until either the version of PowerShell reaches end-of-support or the version of Ubuntu reaches end-of-support.

  • The Supported icon indicates that the version of the OS or PowerShell is still supported
  • The Out of Support icon indicates the version of PowerShell is no longer supported on that version of the OS
  • The In Test icon indicates that we haven't finished testing PowerShell on that OS
  • The Not Supported icon indicates that the version of the OS or PowerShell isn't supported
  • When both the version of the OS and the version of PowerShell have a Supported icon, that combination is supported
Ubuntu 7.0 (LTS) 7.1 7.2 (LTS-current) 7.3
Supported 22.04 (LTS) Not Supported Out of Support Supported Supported
Supported 20.04 (LTS) Out of Support Out of Support Supported Supported
Supported 18.04 (LTS) Out of Support Out of Support Supported Supported
Not Supported 16.04 (LTS) Out of Support Out of Support Not Supported Not Supported

Only the LTS releases of Ubuntu are officially supported. Microsoft does not support interim releases or their equivalent. Interim releases are community supported. For more information, see Community supported distributions.

PowerShell is supported on Ubuntu for the following processor architectures.

Ubuntu 7.2 (LTS-current) 7.3
All supported versions x64, Arm32, Arm64 x64, Arm32, Arm64

Installation support

Microsoft supports the installation methods in this document. There may be other methods of installation available from other third-party sources. While those tools and methods may work, Microsoft cannot support those methods.