Installing PowerShell on Ubuntu

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

Note

PowerShell 7.4 is an in-place upgrade that removes previous versions of PowerShell 7. Preview versions of PowerShell can be installed side-by-side with other versions of PowerShell. If you need to run PowerShell 7.4 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 the Package Repository

Microsoft builds and supports a variety of software products for Linux systems and makes them available via Linux packaging clients (apt, dnf, yum, etc). These Linux software packages are hosted on the Linux package repository for Microsoft products, https://packages.microsoft.com, also known as PMC.

Installing PowerShell from PMC is the preferred method of installation.

Note

This script only works for supported versions of Ubuntu.

###################################
# Prerequisites

# 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

# Get the version of Ubuntu
source /etc/os-release

# Download the Microsoft repository keys
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb

# Register the Microsoft repository keys
sudo dpkg -i packages-microsoft-prod.deb

# Delete the Microsoft repository keys file
rm 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

Important

Ubuntu comes preconfigured with a package repository that includes .NET packages, but not PowerShell. Using these instructions to install PowerShell registers the Microsoft repository as a package source. You can install PowerShell and some versions of .NET from this repository. However, the Ubuntu package repository has different versions of the .NET packages. This can cause problems when installing .NET for other purposes. For more information about these problems, see Troubleshoot .NET package mix ups on Linux.

You must choose the feed you want to use to install .NET. You can set the priority of the package repositories to favor one over the other. For instructions on how to set the priorities, see My Linux distribution provides .NET packages, and I want to use them.

Installation via direct download

PowerShell 7.2 introduced a universal package that makes installation easier. Download the universal package from the releases page onto your Ubuntu machine.

The link to the current version is:

  • PowerShell 7.4 (LTS) universal package for supported versions of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell_7.4.2-1.deb_amd64.deb
  • PowerShell 7.3.12 (stable) universal package for supported versions of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.3.12/powershell_7.3.12-1.deb_amd64.deb
  • PowerShell 7.2.19 (LTS) universal package for supported versions of Ubuntu
    • https://github.com/PowerShell/PowerShell/releases/download/v7.2.19/powershell_7.2.19-1.deb_amd64.deb

The following shell script downloads and installs the current preview release of PowerShell. You can change the URL to download the version of PowerShell that you want to install.

###################################
# Prerequisites

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget

# Download the PowerShell package file
wget https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell_7.4.2-1.deb_amd64.deb

###################################
# Install the PowerShell package
sudo dpkg -i powershell_7.4.2-1.deb_amd64.deb

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

# Delete the downloaded package file
rm powershell_7.4.2-1.deb_amd64.deb

# Start PowerShell Preview
pwsh-lts

Uninstall PowerShell

sudo apt-get remove powershell

Support for Arm processors

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

PowerShell paths

  • $PSHOME is /opt/microsoft/powershell/7/
  • The profiles scripts are stored in the following locations:
    • AllUsersAllHosts - $PSHOME/profile.ps1
    • AllUsersCurrentHost - $PSHOME/Microsoft.PowerShell_profile.ps1
    • CurrentUserAllHosts - ~/.config/powershell/profile.ps1
    • CurrentUserCurrentHost - ~/.config/powershell/Microsoft.PowerShell_profile.ps1
  • Modules are stored in the following locations:
    • User modules - ~/.local/share/powershell/Modules
    • Shared modules - /usr/local/share/powershell/Modules
    • Default modules - $PSHOME/Modules
  • PSReadLine history is recorded in ~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt

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're 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.2 (LTS-previous) 7.3 7.4 (LTS-current)
Supported 22.04 LTS (Jammy) Supported Supported Supported
Supported 20.04 LTS (Focal) Supported Supported Supported
Out of Support 18.04 LTS (Bionic) Out of Support Out of Support Out of Support

Only the LTS releases of Ubuntu are officially supported. Microsoft doesn't 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 7.4 (LTS-current)
All supported versions x64, Arm32 x64, Arm32 x64, Arm32

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 can't support those methods.