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.2 is an in-place upgrade that removes previous versions of PowerShell.

If you need to run PowerShell 7.2 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 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. Change the URL to match the version of the target OS.

# 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/20.04/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.2.1 (universal package) for any support version of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.2.1/powershell-lts_7.2.1-1.deb_amd64.deb
  • PowerShell 7.1.5
    • Ubuntu 20.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.1.5/powershell_7.1.5-1.ubuntu.20.04_amd64.deb
    • Ubuntu 18.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.1.5/powershell_7.1.5-1.ubuntu.18.04_amd64.deb
  • PowerShell 7.0.8
    • Ubuntu 20.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.0.8/powershell-lts_7.0.8-1.ubuntu.20.04_amd64.deb
    • Ubuntu 18.04 - https://github.com/PowerShell/PowerShell/releases/download/v7.0.8/powershell-lts_7.0.8-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.2.1-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 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.

  • A ✅ indicates that the version of the OS or PowerShell is still supported
  • A ❌ indicates that the version of the OS or PowerShell isn't supported
  • A 🟡 indicates the version of PowerShell is no longer supported on that version of the OS
  • When both the version of the OS and the version of PowerShell have ✅, that combination is supported
Ubuntu 7.0 (LTS) 7.1 7.2 (LTS-current) 7.3 (preview)
✅ 20.04 (LTS)
✅ 18.04 (LTS)
❌ 16.04 (LTS) 🟡 🟡

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.0 (LTS) 7.1 7.2 (LTS-current) 7.3 (preview)
All supported versions x64, Arm32, Arm64 x64, Arm32, Arm64 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.