How to install and use Microsoft's PowerShell on Linux (and why you should)

Microsoft/Ubuntu/ZDNET

PowerShell is a task automation and configuration management tool, designed and released by Microsoft, that consists of a command-line shell and a powerful scripting language. A lot of intermediate and advanced Windows users depend on this application for many different reasons and are probably concerned about what they’ll do when support for Windows 10 ends next year.

Also: The best Linux distribution of 2024 is MacOS-like but accessible to all

For those whose computers won’t support Windows 11, there’s good news: Linux!

And for those who depend on PowerShell, there’s even better news:

You can install PowerShell on Linux. Let me show you how.

How to install PowerShell on Ubuntu-based distributions

What you’ll need: To make this work, you’ll need a running instance of a Ubuntu-based distribution and a user with sudo privileges. That’s it. Let’s make some magic.

The first thing to do is log into your Linux desktop and open the terminal application.


Show more

There are a few dependencies that must first be installed, which can be done with a single command:

sudo apt-get install -y wget apt-transport-https software-properties-common -y


Show more

Next, we need to download the proper keys so the MS repository can be used. This is done with the following three commands:

source /etc/os-release
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

The first command above copies the release version of your distribution into memory, the second downloads the correct key for your version, and the third command installs the key.


Show more

Also: Why I no longer recommend this Windows-like Linux distro

Update apt with the command:

sudo apt-get update

Finally, install PowerShell with:

sudo apt-get install powershell -y


Show more

How to install PowerShell on Fedora-based distributions

When using a Fedora-based distribution, the installation process looks like this.

1. Import the required security key

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

First, you’ll need to import the necessary security key with the command:

2. Download and add the repository

You can then download and add the required MS repository with a single command:

curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

3. Install PowerShell

PowerShell can now be installed with the following two commands:

sudo dnf makecache
sudo dnf install powershell -y

How to install PowerShell on Arch-based distributions

Finally, we’ll install Powershell on Arch-based Linux distributions. Surprisingly, this is the easiest installation because PowerShell can be installed from AUR (Arch User Repository) with two simple commands:

pacman -Syy
pacman -Ss powershell-bin

How to start PowerShell

Now that you have PowerShell installed, you can start it with the command:

You should now find yourself on the familiar PowerShell prompt, where you can start using this powerful tool as you did in Windows 10.

Also: The 3 most Windows-like Linux distros you can try because change is hard





Source link

Leave a comment