Step by step process to Install Microsoft PowerShell on Ubuntu ?





Are you trying to get Microsoft PowerShell installed on Ubuntu ?

This guide is for you.


PowerShell for Linux is published to package repositories for easy installation and updates. As superuser, register the Microsoft repository once. After registration, you can update PowerShell with sudo apt-get install powershell .

The easiest way to open a Terminal is to use the key combination Ctrl+Alt+T at the same time. Enter snap package command i.e. “snap install powershell –classic” in the Terminal console to initiate installation of PowerShell in Ubuntu.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Ubuntu related queries.

In this context, we shall look into how to install Microsoft Powershell.


More about PowerShell ?

Powershell is a .net-based configuration management and automation tool.

Also, it is an open-source and cross-platform project that can be installed on Windows, macOS, and Linux.

It mainly performs tasks such as automation of repetitive jobs and configuration management. Moreover, it provides an interactive command-line shell and a scripting environment.


Steps to install Microsoft PowerShell on Ubuntu ?

To install Powershell, follow the process given below.


1. Retrieve the Microsoft Repository GPG Keys

As a first step, we retrieve the Microsoft Repository GPG Keys by running the below commands:

root@host [~]# cd /usr/src/
root@host:/usr/src# wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

 2. Next, we install the Microsoft GPG Keys. For that, we use the dpkg command:

root@host:/usr/src# sudo dpkg -i packages-microsoft-prod.deb
Selecting previously unselected package packages-microsoft-prod.
(Reading database … 257148 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb …
Unpacking packages-microsoft-prod (1.0-ubuntu18.04.2) …
Setting up packages-microsoft-prod (1.0-ubuntu18.04.2) …
root@host:/usr/src#

 3. Now, we shall update the repository list to ensure that we have the latest list of packages available.

To do this, run the command below:

root@host:/usr/src# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu eoan InRelease
Hit:2 http://archive.canonical.com/ubuntu eoan InRelease
Get:3 http://security.ubuntu.com/ubuntu eoan-security InRelease [97.5 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu eoan-updates InRelease [97.5 kB]
Get:5 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease [4,002 B]
Hit:6 http://archive.ubuntu.com/ubuntu eoan InRelease
Get:7 http://us.archive.ubuntu.com/ubuntu eoan-backports InRelease [88.8 kB]



Reading package lists… Done
root@host:/usr/src#

 4. Usually, we can install Ubuntu software from multiple software repositories. 

But, in order to install Powershell, we must enable the universe repository. 

Here is the command to do this:

add-apt-repository universe

 5. Now, we install PowerShell. For that, we run the below command.

root@host:/usr/src# apt-get install -y powershell
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
liblttng-ust-ctl4 liblttng-ust0 liburcu6
The following NEW packages will be installed:
liblttng-ust-ctl4 liblttng-ust0 liburcu6 powershell
0 upgraded, 4 newly installed, 0 to remove and 42 not upgraded.
Need to get 57.7 MB of archives.

After this operation, 158 MB of additional disk space will be used.

root@host:/usr/src#

Make sure to enter 'Y' when asked for confirmation during the installation process.


6. Since, we have installed the PowerShell, we now run it. For that, we use the ‘pwsh’ command as shown below.

root@host:/usr/src# pwsh
PowerShell 6.2.4
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /usr/src>

Now the command prompt changes from

root@host:/usr/src#

to

PS /usr/src>

 

How to Uninstall Powershell from Ubuntu ?

If you wish to uninstall the PowerShell then here is the command to uninstall it:

PS /usr/src> apt-get remove powershell

 

How to Install Microsoft PowerShell Using Snap on Ubuntu ?

For simple installation, the PowerShell Core for Linux is also published in the Snap store as well.

Here is the command that we use to install the PowerShell:

root@host:/usr/src# snap install powershell –classic

Before initiating the installation, Ubuntu requires to authenticate. So to proceed, enter the credentials.

After the authentication, the installation begins. After some time, a successful message is shown.

Once we successfully install PowerShell, we can now launch the PowerShell. 

For that, type 'powershell' in the terminal console and it will take you to PowerShell terminal in an instant:

powershell

 

How to Uninstall Using Snap from Ubuntu ?

Here is the command to remove Powershell using snap:

root@host:/usr/src# snap remove powershell


[Need urgent assistance with Ubuntu queries? – We are here to help you. ]


Conclusion

This article will guide you on steps to install PowerShell on #Ubuntu. #PowerShell is a configuration management tool that brings the capabilities of Linux command-line interface (#CLI) control into the historically point-and-click Windows environment to manage Windows servers efficiently in virtual deployments.

With PowerShell and WSL, we can integrate Linux commands into #Windows just as if they were native applications. 

No need to hunt around for Win32 builds of #Linux utilities or be forced to interrupt your workflow to drop into a Linux shell.

To check the PowerShell version installed in your system, you can use either $PSVersionTable or $host command.

To get a list of PowerShell commands:

1. Get-Command gets the commands from #PowerShell modules and commands that were imported from other sessions. 

2. To get only commands that have been imported into the current session, use the ListImported parameter. 

3. Without parameters, Get-Command gets all of the #cmdlets, functions, and aliases installed on the #computer.


Related Post


Keep In Touch

We hope to hear from you.

Accept File Type: jpg,jpeg,png,txt,pdf,doc,docx