Microsoft and Open Source together do not surprise me anymore.
When Microsoft first announced that it is going to open source .NET, I was shocked. But then it open sourced Visual Studio Code, SQL Server, and more.
The last time I paid attention to Microsoft’s love for Open Source (and Linux) was when it announced Bash on Windows. That was big. Linux’s Bash Shell on Windows, thanks to Ubuntu.
When Microsoft announced that it was bringing its command line platform PowerShell on Linux. PowerShell is now open source and is available on Linux and macOS.
What is PowerShell?
PowerShell is a tool which lets you interact with the command-line shell and automate tasks, primarily for Windows. For things like starting a service, running a web request, you need to use the PowerShell (as an administrator) on Windows.
If we go by its official description, it is “a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework.”
Basically, it’s a command line framework that allows administrative tasks on local and remote Windows systems, among other things. Tightly coupled with .NET, PowerShell has been a quite a hit in the Windows domain.
Install PowerShell on Linux using Snap
Linux already has more powerful and versatile shells available at its disposal. I don’t think regular Linux users are going to start using PowerShell, but then, that’s not the aim anyway. PowerShell on Linux is aimed at developers who must use PowerShell or .NET perhaps.
Whatever may be the reason for you to use PowerShell on Linux, you can easily install it using Snap.
First, make sure that Snap support is enabled on your Linux system. Thereafter, all you have to do is to use the following command:
sudo snap install powershell --classic
If you would rather not use Snap, you can find installation instructions for various Linux distributions in its documentation. You can find docker images for some, and also find it listed in some of the popular package managers.
Install PowerShell using Microsoft Repository on Ubuntu
If you are using Ubuntu, you can set up the official Microsoft repository and install PowerShell from it. First, update your system:
sudo apt update
Now, you should install some prerequisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
Now, get the version of Ubuntu you are using.
source /etc/os-release
Remember that, distributions like Pop!_OS, Linux Mint, etc. use Ubuntu at its base. So, on the next step, where we need the VERSION_ID, it implied the version code of Ubuntu, which the distribution is based.
Download and register the Microsoft repository keys. Just copy and paste the command, one by one.
wget -q <https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb>
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
Now, you can update the software sources on the system and install PowerShell.
sudo apt update
sudo apt-get install -y powershell
That’s it. You can log in to PowerShell, by issuing the command:
pwsh
Unlike the Snap version, there is no GUI icon to appear on the app menu.
For beginners, you can start learning PowerShell by following the PowerShell documentation. You can find more about it on its GitHub repository:
💬Have you tried PowerShell on Linux? Let me know your thoughts!