In this tutorial, we learn the steps to install Microsoft Windows PowerShell in Ubuntu 22.04 Jammy JellyFish Linux using the command terminal.
Windows PowerShell is both a command-line shell and a scripting language with more than 130 command-line utilities called cmdlets (command-lets) that follow extremely consistent syntax and naming conventions and can be extended with custom cmdlets.
Instructions are issued using cmdlets. A cmdlet is a single feature for manipulating an object. They use a verb-noun syntax, meaning a verb and a noun separated by a hyphen. Parameters are marked with a preceding “-“.
PowerShell is an object-oriented shell, which means that the input and output of commands are usually objects. The connection of commands is represented by the so-called ” pipe ” command: ” |”. You can read detailed information about the pipeline and its application here.
Earlier Microsoft Windows PowerShell was only a Windows software but later it was made open-source and cross-platform by its developers on 18 August 2016. The former is built on the .NET Framework, the latter on .NET Core.
- Steps to install Microsoft PowerShell in Ubuntu 22.04 LTS
Steps to install Microsoft PowerShell in Ubuntu 22.04 LTS
The steps are given here can be used on Ubuntu 20.04 LTS Focal Fossa and other versions as well. Including other Debian and Ubuntu-based Linux OS such as Linux Mint, Elementary, MX Linux, Kali, and more…
#1st method using Snap
1. Use Snap to install PowerShell
The best way to install Powershell is to use pre-installed Snap package manager on Ubuntu operating systems. This universal package manager is enabled by default on the system and can be used to easily install popular software. Hence, run:
sudo snap install powershell --classic
#2nd method using APT
2. Update Ubuntu 22.04
First, perform the system update command that will install the latest available security and other updates. This will also refresh the Apt package manager cache.
sudo apt update && sudo apt upgrade
Also install curl, gnupg2, and HTTPS support:
sudo apt install curl apt-transport-https gnupg2 -y
3. Add Powershell repository on Ubuntu 22.04
Well, even though Microsoft Powershell is open source but it is not available to install via Ubuntu’s official repository. Hence, we have to add the repo officially offered by the developers of this software.
echo "deb [arch=amd64,armhf,arm64 signed-by=/usr/share/keyrings/powershell.gpg] \ https://packages.microsoft.com/ubuntu/20.04/prod focal main" \ | sudo tee /etc/apt/sources.list.d/powershell.list
4. Add GPG Key
To authenticate the packages we will receive through our newly added PowerShell repository are as they were published by its developers, we need to add the GPG key used to sign the packages.
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/powershell.gpg >/dev/null
Run system update, again to refresh the APT cache:
sudo apt update
5. Install Microsoft PowerShell on Ubuntu 22.04
Well, we have configured all the things we required to install PowerShell on Ubuntu and other similar Linux systems. Now, let’s use the APT package manager and set up PowerShell.
sudo apt install powershell -y
6. Start the Powershell
To run the PowerShell go to the Application launcher and search for “Powershell“, as it icon appears, click to run the same. Alternatively, you can directly switch to it from your terminal by typing –
7. How to update/upgrade
In the future, if you want to download and install the latest version of Powershell in future, then use one of the given commands as per the method you have used to install it.
sudo snap refresh powershell
For APT method
sudo apt update && sudo apt upgrade
8. Uninstall or Remove Linux Powershell
Those who don’t want this command line software can remove it easily. Again the method you have chosen to install the software, use the same to uninstall it.
sudo snap remove powershell
sudo apt remove powershell
Also, remove Repository
sudo rm /etc/apt/sources.list.d/powershell.list sudo rm /etc/apt/sources.list.d/microsoft-prod.list
With PowerShell, you can start both simple commands (e.g. display the current time) and very complex applications (e.g. automation solutions). The combination of several commands is also possible (“pipelining”). Alternatively, even self-developed commands can be built into the console. For more information visit the official website.