PowerShell (known as pwsh in its cross-platform version, PowerShell 7+) is Microsoft’s open-source shell and scripting language.
Installing it on Linux allows you to run PowerShell scripts, cmdlets, and modules alongside native Linux tools.
We’ll use WSL (Windows Subsystem for Linux) — with Ubuntu 24.04 LTS — as the main example, though the process is similar on other distros.
🧩 Prerequisites
-
WSL Installed:
Ensure WSL is set up (Windows 10 2004+ or Windows 11).
To install WSL, open PowerShell as Administrator and run:wsl --installThis installs Ubuntu by default. After reboot, open Ubuntu and update your packages:
sudo apt update && sudo apt upgrade -y -
Internet Access: Required for downloading packages.
-
Admin Rights: Use
sudofor administrative tasks. -
WSL 2 Recommended: Check or set version:
wsl -l -v wsl --set-version <distro> 2
⚙️ Installing PowerShell in WSL (Ubuntu)
1. Launch Your WSL Distribution
Open Windows Terminal or search Ubuntu in the Start menu to start your WSL session.
2. Update Package Lists
sudo apt update && sudo apt upgrade -y3. Add Microsoft’s GPG Signing Key
curl https://packages.microsoft.com/keys/microsoft.asc | \
sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/nullThis imports Microsoft’s trusted signing key.
4. Add Microsoft Repository
PowerShell packages are hosted on Microsoft’s official repositories.
Use the command below — it dynamically uses your Ubuntu $VERSION_ID:
sudo curl -o /etc/apt/sources.list.d/microsoft-prod.list \
https://packages.microsoft.com/config/ubuntu/$VERSION_ID/prod.listIf your version (like Ubuntu 25.10) isn’t yet available, manually download from GitHub:
wget https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell_7.5.4-1.deb_amd64.deb
sudo dpkg -i powershell_7.5.4-1.deb_amd64.deb
sudo apt-get install -fFor unsupported releases, use a fallback (e.g., Ubuntu 24.04 repository):
sudo curl -o /etc/apt/sources.list.d/microsoft-prod.list \
https://packages.microsoft.com/config/ubuntu/24.04/prod.list
sudo apt-get install -f5. Update Package Lists Again
sudo apt update6. Install PowerShell
sudo apt install -y powershellThe installation downloads ~150–200 MB and installs the latest stable PowerShell (7.5+ as of Oct 2025).
7. Verify Installation
pwsh --versionExample output: PowerShell 7.5.4
Launch PowerShell:
pwshCheck detailed version info:
$PSVersionTableYou’ll see output like:
PSVersion 7.5.4 PSEdition Core OS Ubuntu 24.04.3 LTS Platform Unix
Exit PowerShell anytime with:
exit⚡ Optional: Set PowerShell as Default Shell
Launch PowerShell automatically when WSL starts:
echo '/usr/bin/pwsh' | sudo tee -a /etc/passwdOr start WSL directly into PowerShell from Windows:
wsl --exec pwsh🔄 Post-Installation Tips
-
Update PowerShell regularly:
sudo apt update && sudo apt upgrade -y -
Install .NET SDK (optional):
sudo apt install -y dotnet-sdk-8.0 -
Access Windows Files from WSL PowerShell:
cd /mnt/c/Users notepad.exe -
Uninstall PowerShell:
sudo apt remove --purge powershell && sudo apt autoremove
🧰 Troubleshooting
GPG Key Error:
Re-run the key import:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -404 Repo Error:
Ensure your Ubuntu version matches:
lsb_release -aWSL Issues:
Restart your subsystem:
wsl --shutdown🚀 Performance Notes
PowerShell runs natively inside WSL, with near-native speed under WSL 2.
For large automation scripts or CI/CD jobs, always use:
wsl --set-default-version 2🐧 Other Linux Distributions
| Distro | Installation Summary |
|---|---|
| Debian | Use https://packages.microsoft.com/config/debian/12/prod.list |
| Fedora / RHEL / CentOS | |
| Arch Linux | |
| openSUSE | |
For full details, see the official Microsoft docs:
👉 Install PowerShell on Linux
With this setup, you’ll have a fully functional PowerShell environment inside WSL — perfect for scripting, automation, and managing cross-platform workflows.