Linux Mint

How to Install PowerShell on Linux Mint 21

Most of the users don’t like to perform repetitive tasks and, select and click way to manage operations. When working with multiple operations, it is always recommended to select a program that has the ability to automate many tasks.

According to the user’s perspective, Microsoft has offered a program we know as PowerShell that is built on Microsoft .Net Framework. Powershell is a scripting language that automates administrative tasks through an interactive session with command-line shell.

It is a cross-platform program consisting of a modern command shell. It handles administrative tasks and configuration management through cmdlets which are pronounced as command-lets. Powershell is also a scripting language that can create classes, scripts, test and deploy solutions.

Install Powershell on Linux Mint 21

Powershell is an open-source program supported by different operating systems including Linux. The guide will show you how you can install it on the Linux Mint 21 system with the help of two different approaches.

  1. Through apt
  2. Through snap

Let’s perform both approaches and find out which is the easier one.

i: Install Powershell on Linux Mint via apt

To install PowerShell using apt repository, we need to install Microsoft keys and repository first. The few mentioned-below commands are need to be followed carefully:

Step 1: Upgrade the Linux Mint 21 system using the given command to update all system packages:

$ sudo apt-get upgrade -y

Step 2: Next step is to install the required dependencies that helps to run PowerShell on Linux Mint:

$ sudo apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https curl -y

Step 3: Now, add the Microsoft GPG key:

$ curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/powershell.gpg > /dev/null

Step 4: Import the repository to the Linux Mint system:

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

Step 5: Refresh the system’s packages:

$ sudo apt update

Step 6: Now, we can install PowerShell on the Linux Mint 21 after successfully installing repositories and keys. Run the mentioned command to let installation begin:

$ sudo apt install powershell -y

Step 7: Run the PowerShell on Linux Mint system by typing pwsh on terminal:

$ pwsh

ii: Install PowerShell on Linux Mint 21 via Snap

Snap packages are another way to install PowerShell on the Linux Mint 21 system. For this, we need to ensure if snap package manager exists in our system by running the command:

$ snap --version

If it is not enabled then read the guide to enable snap on Linux Mint.

Now, with the help of the following snap command you can install PowerShell on system:

$ sudo snap install powershell --classic

You can launch it on system by running pwsh on terminal:

$ sudo pwsh

Uninstall Powershell from Linux Mint 21

We can also uninstall or delete PowerShell from Linux Mint 21 system using following methods:

  1. Through apt (If installed through apt)
  2. Through Snap (If installed through snap)

i: Delete PowerShell from Linux Mint using apt

To delete PowerShell from Linux Mint 21 system, executing the command given-below:

$ sudo apt remove powershell -y

Also, we need to remove the added repositories and GPG keys from the system. You can do this by copying the mentioned command in terminal:

sudo rm /etc/apt/sources.list.d/powershell.list /usr/share/keyrings/powershell.gpg

ii: Delete PowerShell from Linux Mint using Snap

To remove PowerShell through snap packages, execute the following command:

$ sudo snap remove powershell

Conclusion

PowerShell is the popular program from Microsoft for task automation. It performs operations using a command shell and reduces the problem of repetitive tasks. PowerShell is the advanced update of CMD that comes with more enhancing features in it. This article has covered two ways to install PowerShell in Linux Mint 21 system i-e through apt repository and through snap packages.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.