How to Install PowerShell Core on Ubuntu Linux

This article explains how to install PowerShell Core for Linux on Ubuntu Linux.

Microsoft PowerShell Core for Linux is a task-based command-line shell and scripting language built on. NET. It’s a core feature of Windows systems, and Microsoft has also made it available to Linux systems, including Ubuntu.

PowerShell can be used as an automation and configuration management platform. It consists of a cross-platform (Windows, Linux, and macOS) command-line shell and associated scripting language.

For more about PowerShell Core on Linux, please go to its homepage

There are many ways to install PowerShell Core on Ubuntu. The two methods below are the easiest ways to install the program on Ubuntu.

Install PowerShell Core via Repository

The first method of installing PowerShell core on Ubuntu is via its repository. Next, you’ll have to download the repository file, install it, update Ubuntu, and install the core packages.

Run the commands below to download and install the repository key file to get the repository installed.

For Ubuntu 16.04:

cd /tmp
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

For Ubuntu 18.04:

cd /tmp
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

After downloading the correct key file and installing it for your system, run the commands below to refresh Ubuntu package lists and install PowerShell

sudo apt update
sudo apt install powershell

#Start PowerShell
pwsh

That’s it!

Install PowerShell via Snap

Another way to get PowerShell installed is via Snap package management. Snaps are containerized software packages that are simple to create and install.

They are applications packaged with all their dependencies to run on all popular Linux distributions from a single build, allowing them to update automatically and roll back gracefully….

This might be the easiest way to get PowerShell on Linux systems, including Ubuntu… To install, run the commands below: install Snap…

sudo apt update
sudo apt install snapd

Then, run the commands below to get PowerShell installed via Snap.

sudo snap install powershell --classic

After installing, you can go to the Activities Overview board and search for PowerShell to launch it. When it opens, you should see a message similar to the one below:

PowerShell 6.1.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/richard> 

Enjoy!

You may also like the post below:

Frequently Asked Questions

What is PowerShell Core and why should I install it on Ubuntu?

PowerShell Core is a cross-platform command-line shell and scripting language developed by Microsoft. It allows users to automate tasks and manage configurations on Linux systems, making it a valuable tool for system administrators and developers.

How can I install PowerShell Core on Ubuntu using the repository method?

To install PowerShell Core via the repository, you need to download the appropriate repository file for your Ubuntu version, install it, update your package lists, and then install PowerShell using the commands provided in the tutorial.

What are Snap packages and how do I use them to install PowerShell?

Snap packages are containerized software that include all dependencies needed to run on various Linux distributions. To install PowerShell via Snap, you first need to install Snapd, then run the command 'sudo snap install powershell –classic' to get PowerShell installed.

Can I run PowerShell on other Linux distributions besides Ubuntu?

Yes, PowerShell Core is designed to be cross-platform and can run on various Linux distributions, including Fedora, CentOS, and others, in addition to Ubuntu.

What should I do if I encounter issues while installing PowerShell on Ubuntu?

If you face issues during installation, ensure that your system is updated and that you have the correct repository file for your version of Ubuntu. You can also check the official PowerShell documentation or community forums for troubleshooting tips.

Categories:

Leave a Reply

Your email address will not be published. Required fields are marked *