PowerShell is the default ‘Terminal’ application for Windows along with the command prompt, it has its own set of commands which is very different from the commands which are used on UNIX-like operating systems such as GNU/Linux. It is tightly coupled around the .NET framework of the Windows ecosystem.
You don’t really need a Windows Terminal on Linux because there is nothing Bash cannot do. Perhaps the only reason you could need this is either you need to work on something .NET framework related, or you are an experienced Windows user, and you just prefer anything but bash.
Also, Read – Windows Terminal to easily manage WSL instances
Installing PowerShell on Linux
In this tutorial, we will take a look at the installation process of this Windows tool on different Linux distributions and also try to do some basic tasks to check if it is working properly in the Linux environment.
On Fedora Workstation
We just have to register the Microsoft Red Hat repository and then install this app, just open a Terminal and type the following command :
# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Installation
sudo dnf install --assumeyes powershell
On Debian-based Linux
Just open a Terminal and type the following commands :
# Install system components
sudo apt update && sudo apt install -y curl gnupg apt-transport-https
# Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# Register the Microsoft Product feed
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
# Install
sudo apt update && sudo apt install -y powershell
On Ubuntu Linux
On Ubuntu Linux, PowerShell can be installed by typing the following commands in your Terminal :
# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Installation
sudo apt-get install -y powershell
On Arch Linux-based distributions
This package can be easily installed on your Arch-based distributions from the Arch User Repository, so just open a Terminal and install it using your favorite AUR helper :
# If you use yay :
yay -S powershell-bin
# If you use paru helper :
paru -S powershell-bin
Running basic commands
Now, to launch this tool directly from the Terminal, simply type :
pwsh
As you can see, the command line options are completely different from that of bash, and even the prompt has changed. Let’s try navigating through our system using windows only commands.
# To change directory
chdir /
# to list the contents of the current directory
ls
# To go to the home directory
cd ./home/
Summary
PowerShell is now open-source, and it is one of the major steps Microsoft has taken in order to acquire more market share in the cloud computing field. The whole ‘Microsoft loves Linux’ program is really shady and even now with the WSL (Windows Subsystem for Linux), Microsoft has prevented even more developers from using any Linux distribution natively.
But credit, where it’s due, making anything open source, is just the right thing to do, and if any vulnerability is discovered, it can be discovered and patched really quickly.
References
Microsoft’s official documentation