Table of Contents
PowerShell can be installed on different Linux distributions. Most Linux platforms and distributions have a major release each year and provide a package manager that’s used to install PowerShell.
Installing PowerShell on Ubuntu
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.
Ubuntu | 7.2 (LTS-current) | 7.3 | 7.4 (preview) |
---|---|---|---|
🐧 22.04 (LTS) | 🟢 | 🟢 | 🟢 |
🐧 20.04 (LTS) | 🟢 | 🟢 | 🟢 |
🐧 18.04 (LTS) | 🟢 | 🟢 | 🟢 |
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.
# 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 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.2 (universal package) for any supported version of Ubuntu
https://github.com/PowerShell/PowerShell/releases/download/v7.3.2/powershell_7.3.2-1.deb_amd64.deb - PowerShell 7.2.9 (universal package) for any supported version of Ubuntu
https://github.com/PowerShell/PowerShell/releases/download/v7.2.9/powershell-lts_7.2.9-1.deb_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.2-1.deb_amd64.deb
# Resolve missing dependencies and finish the install (if necessary)
sudo apt-get install -f
Uninstallation
sudo apt-get remove powershell
Installing PowerShell on Red Hat Enterprise Linux (RHEL)
The following table is a list of currently supported versions of PowerShell and the versions of RHEL they’re supported on. These versions remain supported until either the version of PowerShell reaches end-of-support or the version of RHEL reaches end-of-support.
RHEL | 7.2 (LTS-current) | 7.3 | 7.4 (preview) |
---|---|---|---|
🐧 RHEL 7 | 🟢 | 🟢 | 🟢 |
🐧 RHEL 8 | 🟢 | 🟢 | 🟢 |
Installation via Package Repository
RHEL 7 uses yum and RHEL 8 uses the dnf package manager. PowerShell for Linux is published to official Microsoft repositories for easy installation and updates.
On RHEL 7:
# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo yum install --assumeyes powershell
# Start PowerShell
pwsh
On RHEL 8:
# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo dnf install --assumeyes powershell
# Start PowerShell
pwsh
As superuser, register the Microsoft repository once. After registration, you can update PowerShell with sudo dnf/yum upgrade powershell.
Installation via Direct Download
Starting with version 7.2, PowerShell is distributed as a universal RPM package. Previous versions of PowerShell had separate package for each OS. Download the RPM package you need onto your CentOS machine.
Use the following shell command to install the latest RPM package on the target version of RHEL. Change the URL in the following shell commands to match the version you need.
#On RHEL 7:
sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v7.3.2/powershell-7.3.2-1.rh.x86_64.rpm
#On RHEL 8:
sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.3.2/powershell-7.3.2-1.rh.x86_64.rpm