VOOZH about

URL: https://www.geeksforgeeks.org/installation-guide/how-to-install-powershell-in-linux/

⇱ How to Install PowerShell in Linux? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Install PowerShell in Linux?

Last Updated : 6 Oct, 2021

PowerShell is well-known among Windows administrators. It is a.NET-based task-based command-line shell and scripting language. You can quickly automate tasks for operating system maintenance and much more with PowerShell. PowerShell was once only available for Microsoft Windows. This admin tool, on the other hand, can now be installed and used on Linux.

Installing PowerShell using Snap packages

1. The least complex approach to install PowerShell using snap is as per the following :

sudo snap install powershell --classic
👁 Installing powershell with snap
Installing PowerShell using snap

2. Now you can simply launch PowerShell by using a simple command :

pwsh
👁 running powershell in linux
Opening PowerShell

Installing PowerShell using a package repository

Installing PowerShell from a package repository is the preferred approach in Linux.

1. First update list of system packages using below command :

sudo apt-get update
👁 sudo apt update
Update system source

2. Install pre-requisite packages using the below command :

sudo apt-get install -y wget apt-transport-https software-properties-common
👁 installing prerequisite packages for powershell inlinux
Installing pre-requisite packages

3. Now download the Microsoft repository GPG keys :

wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
👁 microsoft powershell repository GPG keys
Downloading Microsoft GPG key

4. Then register the Microsoft repository GPG keys :

sudo dpkg -i packages-microsoft-prod.deb
👁 Regitstering Microsoft repository GPG keys
Registering GPG key

5. Then update the system source :

sudo apt-get update
👁 sudo apt udpate
Updating system source

6. Enabling the universe repositories :

sudo add-apt-repository universe
👁 enabling universe repository
Enable universe repositories

7. Now we can finally install PowerShell using the below command :

sudo apt-get install -y powershell
👁 command to install powershell in linux
Installing PowerShell

8. Now we can start PowerShell by simply typing the below command :

$ pwsh
👁 Running the powershell in linux
Starting PowerShell
Comment