How to Install PowerShell on Ubuntu 20.04 LTS

Microsoft PowerShell is a versatile and industry-leading scripting language that can be used for automation. It is also often paired with other technologies like CI/CD platforms, making it possible to build solutions without much effort quickly! No matter what kind of input you are looking at, whether it’s text or object data, PowerShell will return .NET objects when executed; this means there is no need whatsoever to parse out information from output messages since all values are already inside them.

In the following tutorial, you will learn how to install PowerShell on Ubuntu 20.04 LTS Focal Fossa. The tutorial will use the command line terminal with complete steps to install the official repository and tips on updating and removing the software securely and adequately.

Update Ubuntu

Before proceeding with the tutorial, it is good to ensure your system is up-to-date with all existing packages.

sudo apt update && sudo apt upgrade

Install Dependencies

The following dependencies will need to be installed. Most of these packages would already be present on your system, but running the command can help ensure they’re installed.

sudo apt install curl apt-transport-https gnupg2 -y

Install PowerShell

First, you will need to import the GPG and the repository. Luckily this is straightforward, and you will always have the most up-to-date version available on your Ubuntu system.

Import the GPG key using the following command.

sudo wget -O- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/powershell.gpg

The above command should work on most setups; any trouble, add sudo to the command before curl.

Next, import the repository.

echo deb [arch=amd64,armhf,arm64 signed-by=/usr/share/keyrings/powershell.gpg] https://packages.microsoft.com/ubuntu/20.04/prod focal main | sudo tee /etc/apt/sources.list.d/powershell.list

Once done, run an APT update to reflect the new additional repository.

sudo apt update

Now you can install PowerShell using the following command.

sudo apt install powershell -y

Activate PowerShell

Now that you have completed the installation to activate PowerShell, use the following command.


Example of PowerShell Instance:

How to Install PowerShell on Ubuntu 20.04 LTS

And that is it, and you have successfully installed the latest PowerShell version on your Ubuntu system.

PowerShell Commands Example

Now that you have logged into your terminal, some common examples of how to use PowerShell are as follows.

Print Help


Detail PowerShell information


List a directory


Print previous command history


List process information


Exit PowerShell instance


How to Update PowerShell

To check for updates using the command line, use the following command to allow a blanket check for any updates across all APT packages.

sudo apt update && sudo apt upgrade

How to Remove (Uninstall) PowerShell

When you no longer want PowerShell installed on your system, use the following command to remove it.

sudo apt autoremove powershell -y

Next, remove the repository using the following command.

sudo rm /etc/apt/sources.list.d/powershell.list

For good housekeeping and security, remove the GPG key as follows.

sudo rm /usr/share/keyrings/powershell.gpg

Comments and Conclusion

In the tutorial, you have learned how to install PowerShell on Ubuntu 20.04 LTS Focal Fossa.

Microsoft PowerShell is a powerful tool that can be used for system management and automation. If you’re not already familiar with PowerShell, we encourage you to check it out. It’s a great way to save time and automate tedious tasks.

More information about PowerShell and how to use it, amongst many other things, can be found in the official documentation.

Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!