How to Install PowerShell on Linux Mint 21?
PowerShell is a widely used terminal that comes by default in Microsoft Windows. It can perform all the operations usually carried out using the System’s Graphical User Interface. Because of its wide support and extended functionality, PowerShell is also available for Linux-based machines. This post will provide a detailed guide to installing PowerShell on Linux Mint 21 (the latest LTS of the Linux Mint)
Approach #1: Install PowerShell on Linux Mint 21 From its RepositoryPowerShell is unavailable in the default repository of Linux Mint. However, we can add its repository and the GPG key to tell the system that it is the secure installation medium. This section will guide you to install PowerShell using the repository of PowerShell.
Step 1: Add the DependenciesFirst, add the required dependencies that are required, and your system may be missing. For this, use the command written below.
$ sudo apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https curl
Step 2: Add the GPG Key of PowerShell’s RepositoryAfter that, add the GPG key of PowerShell’s repository to your system so that it will accept the repository.
$ curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/powershell.gpg > /dev/null
Step 3: Add PowerShell’s RepositoryNow, add the PowerShell repository to your Linux Mint 21 system via the command.
Note: It can be seen that we are adding the Ubuntu 22.04 support of the repository as the Linux Mint 21 repository has not been released.
$ 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 4: Update Packages and Install PowerShellOnce the first three steps are performed successfully, now, it is time to update the system’s packages via the command.
After that, use the command written below to install PowerShell on Linux Mint 21 through the apt package manager.
$ sudo apt update
$ sudo apt install powershell
Step 4: Check the Version.To confirm the installation, use the command to check the version.
$ pwsh --version
Approach #2: Install PowerShell on Linux Mint 21 From Snap (CLI)Snap is a well-supported and widely used application manager for Linux-based systems. It has strong support to install the packages through the CLI. Do follow the steps to install PowerShell on Linux Mint 21.
Step 1: Enable the Snap SupportWe need to remove the “nosnap.pref” file to enable the system to receive packages from the snap. To do so, use the commands below to remove and update the system packages.
Now, install the snap daemon by following the command below.
$ sudo rm /etc/apt/preferences.d/nosnap.pref $ sudo apt update
$ sudo apt install snapd
Step 2: Install PowerShellOnce the snap support is enabled, write the command in the terminal to get the PowerShell. Ensure the package name is written correctly (powershell –classic).
The output has verified that PowerShell version 7.3.1 has been installed on the system.
$ sudo snap install powershell --classic
Remove PowerShell From Linux Mint 21The uninstallation method depends on how you installed the package. For instance, if the package is installed using the snap, it will be removed using snap, and if the apt package manager is used to install it, it will be removed using the apt. Here, we will be discussing both methods.
Through aptIf you have installed PowerShell from the apt package manager, you can remove it via the command.
$ sudo apt autoremove powershell
Through SnapIf the package is installed using the snap, it can be removed using the command.
The output shows that the PowerShell has been removed successfully.
$ sudo snap remove powershell