If you use PowerShell on Windows 10, but you also require to use a Linux distribution (such as Ubuntu) for work, you can now install the Microsoft command-line shell and scripting language in the most popular flavors of the open source operating system.
At the time of this writing, you can install PowerShell 7, which is built on .NET Core 3.1, but it’s backward compatible with the modules for older releases.
In this guide, you’ll learn the steps to install PowerShell 7 on Ubuntu using graphical user interface (GUI) or command line. (These are the steps to install the tool on Windows 10.)
- How to install PowerShell using Ubuntu Software
- How to install PowerShell using package installer
- How to install PowerShell using Snap command on Ubuntu
- How to install PowerShell using using Package Repository on Ubuntu
How to install PowerShell using Ubuntu Software
-
Open Ubuntu Software app.
-
Search for PowerShell.
-
Select the powershell option.
-
Click the Install button.
Once you complete the steps, you can access the app using the pwsh on the Linux Terminal.
If you want to uninstall it, then on the “Ubuntu Software” app, click the Installed tab, and click the Remove button for PowerShell.
How to install PowerShell using package installer
To install PowerShell on Linux using GUI installer, use these steps:
-
Under the “Assets” section, click the powershell_7.x.x-x.ubuntu.xx.xx_amd64.deb depending on the version of Ubuntu on your device.
Quick note: PowerShell is also available for other flavors of Linux, including CentOS, Alpine, Red Hat, and Debian. -
Save the file on your device.
-
Double-click the *.deb file to launch the installer.
-
Click the Install button.
Once you complete the steps, PowerShell will install, and you can launch it from the Terminal using the pwsh
command.
If you run into dependencies problems, then use the steps below to install PowerShell using command lines.
How to install PowerShell using Snap command on Ubuntu
To update the PowerShell app on Linux, use these steps:
-
Open Terminal.
-
Type the following command to install PowerShell and press Enter:
sudo snap install powershell --classic
After you complete the steps, you can start the Microsoft scripting tool using the pwsh
command in the Terminal.
If you want to uninstall the tool, from the Terminal, type the sudo snap remove powershell
command.
How to install PowerShell using using Package Repository on Ubuntu
To install PowerShell on Linux using Package Repository, use these steps:
-
Open Terminal.
-
Type the following command to download the Microsoft repository GPG keys and press Enter:
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
-
Type the following command to register the Microsoft repository GPG keys and press Enter:
sudo dpkg -i packages-microsoft-prod.deb
-
Type the following command to update the list of products and press Enter:
sudo apt-get update
-
Type the following command to enable the “universe” repositories and press Enter:
sudo add-apt-repository universe
-
Type the following command to install PowerShell on Linux and press Enter:
sudo apt-get install -y powershell
After you complete the steps, PowerShell will install on Ubuntu 18.04, and you can start it using the pwsh
command.
When you no longer need the command line tool, use the sudo apt-get remove powershell
command in the Terminal to uninstall it.
PowerShell dependencies
PowerShell builds portable binaries for all Linux distributions. However, Microsoft .NET Core runtime requires several dependencies on different flavors of Linux as well as PowerShell.
For example, on Ubuntu 18.04 and higher, the installation depends on libc6, libgcc1, libgssapi-krb5-2, liblttng-ust0, libstdc++6, libcurl3, libunwind8, libuuid1, zlib1g, libssl1.0.0, and libicu60.
If during the installation process, you come across dependency problems, you’ll have to find and install the components manually.
While preparing this guide, the installation of PowerShell 7 also required liblttng-ust0, libssl1.0.0, and libicu60. If you have the same issues, then you can get these packages with these commands:
-
Open Terminal.
-
Type the following command to install liblttng-ust0 and press Enter:
sudo apt install liblttng-ust0
-
Type the following command to download libicu60 and press Enter:
wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu60_60.2-3ubuntu3.1_amd64.deb
-
Type the following command to install libicu60 and press Enter:
sudo dpkg -i libicu60_60.2-3ubuntu3.1_amd64.deb
-
Type the following command to download libssl1.0.0 and press Enter:
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
-
Type the following command to install libicu60 and press Enter:
sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
-
Type the following command to install PowerShell and Enter:
sudo apt-get install -y powershell
Once you complete the steps, PowerShell 7 should install on your Linux device.
In case that you need to download a different version of the dependency packages, you can find them at the Ubuntu package repository.