Microsoft’s PowerShell is a robust task automation and configuration management tool known for its command-line interface and powerful scripting capabilities. Originally designed and released by Microsoft, PowerShell has been a staple for intermediate and advanced Windows users looking to streamline their operations. With the announcement that support for Windows 10 will end next year, many users are exploring alternatives. For those whose computers won’t support Windows 11, transitioning to Linux is a viable option. Furthermore, for users who have depended heavily on PowerShell, there’s even better news: PowerShell can actually be installed and used on Linux systems. This guide will walk you through the process of installing PowerShell on different Linux distributions and how to get started using it.
Installation on Ubuntu-Based Distributions
To install PowerShell on an Ubuntu-based distribution, you need a running instance of the distribution and a user with sudo privileges. Start by logging into your Linux desktop and opening the terminal application. There are a few essential dependencies that must be installed first. This can be quickly done with the following command:
sudo apt-get install -y wget apt-transport-https software-properties-common -y
After installing these dependencies, the next step involves downloading the appropriate keys to use the Microsoft repository. This is accomplished through a series of commands:
source /etc/os-releasewget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.debsudo dpkg -i packages-microsoft-prod.deb
In these commands, the first one copies the release version of your distribution into memory, the second downloads the correct key for your version, and the third installs the key. Once these steps are completed, update the apt package index with the following command:
sudo apt-get update
Now, you can install PowerShell with the straightforward command:
sudo apt-get install powershell -y
With this, PowerShell should be successfully installed on your Ubuntu-based Linux distribution. You can now proceed to use it just like you would on a Windows system.
Installation on Fedora-Based Distributions
If you are using a Fedora-based distribution, the steps to install PowerShell differ slightly. Begin by opening the terminal and importing the necessary security key with the following command:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
Following this, download and add the required Microsoft repository with a single command:
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
With the repository added, you can create a package cache and proceed to install PowerShell using the following commands:
sudo dnf makecachesudo dnf install powershell -y
This process should enable you to install PowerShell successfully on any Fedora-based Linux distributions, giving you the power and flexibility you were accustomed to on Windows.
Installation on Arch-Based Distributions
For users of Arch-based distributions, installing PowerShell is even more straightforward, courtesy of the Arch User Repository (AUR). Start by synchronizing the package database with the command:
sudo pacman -Syy
Next, search for the PowerShell package and install it with:
sudo pacman -Ss powershell-bin
These simple steps allow for a swift installation of PowerShell on Arch-based systems, making it the easiest process compared to other distributions.
How to Start Using PowerShell
After installing PowerShell on your preferred Linux distribution, starting it is quite simple. Open your terminal application and type the command:
pwsh
This should bring up the familiar PowerShell prompt, where you can start leveraging PowerShell’s extensive capabilities. Whether you are running scripts to automate tasks, managing system configurations, or exploring new commands, PowerShell on Linux offers the same robust functionality as it did on Windows.
With Linux becoming a more feasible option for users transitioning from Windows, the ability to install and use PowerShell across different distributions adds a layer of convenience and capability. It ensures that PowerShell remains a valuable tool irrespective of the underlying operating system, providing users with continuity and familiarity in their workflows.