Keeping the same shell and scripting workflow across Windows, Linux, and Azure is easier when the command language behaves the same everywhere. If you need to install PowerShell on Ubuntu, the Linux build gives you the same object-based pipeline, remoting model, and module ecosystem you would use on Windows. That keeps scripts moving between hosts with less rewriting.
PowerShell is not part of Ubuntu’s default repositories. The best install path depends on your Ubuntu release: Microsoft publishes the powershell APT package for Ubuntu 24.04 and 22.04, while Ubuntu 26.04 currently needs the official universal .deb from GitHub because the 26.04 Microsoft repository does not yet contain the powershell package.
This APT and universal
.debworkflow targetsamd64systems. Microsoft documents Arm support through the PowerShell binary archive method instead.
Install PowerShell on Ubuntu
Choose the method that matches your Ubuntu release before adding a repository or downloading a package. The repository method is easier to maintain because updates flow through APT, but the GitHub .deb fallback is the working path for Ubuntu 26.04 until Microsoft publishes the repository package for that release.
| Ubuntu Release | Method | Update Behavior |
|---|---|---|
| 24.04 and 22.04 | Microsoft APT repository | Updates through APT with the rest of your package sources |
| 26.04 | Official GitHub .deb fallback | Use the update helper or install a newer verified .deb |
For Debian hosts, use the separate install PowerShell on Debian workflow because Debian uses different release names and repository paths.
Check Your Ubuntu Release and Architecture
Confirm the release and processor architecture before choosing the install path:
lsb_release -rs
lsb_release -cs
dpkg --print-architecture
24.04 noble amd64
Use the repository method when the release output is 24.04/noble or 22.04/jammy on amd64. Use the GitHub .deb fallback when the release output is 26.04/resolute on amd64. If you only need help identifying the system, the check Ubuntu version guide covers the common release commands in more detail.
For Ubuntu on WSL, run the release check inside the WSL distro. WSL does not change the package source choice, but the install stays inside that WSL environment rather than Windows PowerShell.
Update Ubuntu Before Installing PowerShell
Refresh the package index and apply pending upgrades before adding a new repository or installing a downloaded package. This reduces dependency churn and avoids mixing stale package metadata with the Microsoft package source.
sudo apt update && sudo apt upgrade -y
These commands use
sudofor steps that need root privileges. If your account does not have sudo access yet, follow the guide on how to add a new user to sudoers on Ubuntu.
The -y flag auto-confirms the upgrade prompt. Omit it if you want to review the package transaction before APT proceeds.
Install PowerShell Repository Prerequisites
Ubuntu desktop installs often already have most of these tools, but server, cloud, and minimal images may not. Install the prerequisite set so APT can trust Microsoft’s HTTPS endpoint and detect the correct Ubuntu release automatically.
sudo apt install ca-certificates curl gpg lsb-release -y
ca-certificateslets APT andcurltrust Microsoft’s HTTPS endpoints.curldownloads the signing key and is also useful elsewhere if you need the curl command guide.gpgconverts the ASCII key into the binary keyring format APT expects.lsb-releasereports your Ubuntu version and codename so the repository file points at the correct branch.
Add the Microsoft Repository on Ubuntu 24.04 or 22.04
PowerShell’s APT package comes from packages.microsoft.com. Import Microsoft’s signing key first, then write a DEB822 source file for Ubuntu 24.04 or 22.04. This format keeps the source, suite, architecture, and keyring path explicit.
Microsoft’s documentation also shows a packages-microsoft-prod.deb setup script. The DEB822 commands here use the same upstream repository and signing key, but store the source as a DEB822 .sources file for easier auditing and cleanup.
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/powershell.gpg
The -fsSL flags make curl fail on HTTP errors, stay quiet unless something breaks, and follow redirects. gpg --dearmor converts the downloaded key into a binary keyring file that APT can read directly.
Create the source file only when your system is on a supported repository release and amd64. If the command prints the skip message, use the GitHub .deb method instead.
ubuntu_version="$(lsb_release -rs)"
ubuntu_codename="$(lsb_release -cs)"
ubuntu_arch="$(dpkg --print-architecture)"
if [ "$ubuntu_arch" = "amd64" ] && { [ "$ubuntu_version" = "22.04" ] || [ "$ubuntu_version" = "24.04" ]; }; then
printf '%s\n' \
"Types: deb" \
"URIs: https://packages.microsoft.com/ubuntu/${ubuntu_version}/prod" \
"Suites: ${ubuntu_codename}" \
"Components: main" \
"Architectures: amd64" \
"Signed-By: /usr/share/keyrings/powershell.gpg" | sudo tee /etc/apt/sources.list.d/powershell.sources > /dev/null
else
printf 'Skip the APT repository method on Ubuntu %s for %s. Use the GitHub .deb or binary archive method instead.\n' "$ubuntu_version" "$ubuntu_arch"
fi
Refresh APT after the source file exists, then confirm that the powershell candidate comes from Microsoft:
sudo apt update
apt-cache policy powershell
powershell:
Installed: (none)
Candidate: 7.6.1-1.deb
Version table:
7.6.1-1.deb 500
500 https://packages.microsoft.com/ubuntu/24.04/prod noble/main amd64 Packages
Install PowerShell with APT on Ubuntu 24.04 or 22.04
Install the powershell package after APT shows a Microsoft candidate:
sudo apt install powershell -y
The following NEW packages will be installed: powershell Setting up powershell (7.6.1-1.deb) ...
Install PowerShell from GitHub on Ubuntu 26.04
Ubuntu 26.04 currently has Microsoft repository metadata, but the powershell package is not present in the 26.04 repository index. Microsoft’s supported Ubuntu repository list currently names Ubuntu 24.04 and 22.04, so use the official universal .deb from the PowerShell GitHub releases page as an interim 26.04 path. This installs the same powershell package, but it does not add an update source. If you want a broader explanation of local package installs, see install or remove deb files on Ubuntu.
Install the download prerequisites first if your 26.04 system does not already have them. The python3 package supports the update helper that resolves the current GitHub release.
sudo apt install ca-certificates curl python3 -y
Download the current stable .deb package and Microsoft’s checksum manifest:
POWERSHELL_VERSION=7.6.1
curl -fsSLO "https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb"
curl -fsSLO "https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/hashes.sha256"
Verify the downloaded package against the official hash line. Microsoft’s hash file is UTF-16 encoded, so iconv normalizes it and tr removes carriage returns before sha256sum checks the matching package filename.
iconv -f utf-16 -t utf-8 hashes.sha256 | tr -d '\r' | grep "powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb$" | sha256sum -c -
powershell_7.6.1-1.deb_amd64.deb: OK
Install the local package with APT so dependencies are resolved from your enabled Ubuntu sources:
sudo apt install "./powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb" -y
The following NEW packages will be installed: powershell Setting up powershell (7.6.1-1.deb) ...
Remove the downloaded package and checksum file after installation if you do not need to keep them:
rm -f "powershell_${POWERSHELL_VERSION}-1.deb_amd64.deb" hashes.sha256
Add a PowerShell Deb Update Helper on Ubuntu 26.04
The GitHub .deb method needs a repeatable update command because APT does not know where the downloaded package came from. Create a small helper that resolves the current GitHub release, downloads the matching amd64 package, verifies it against Microsoft’s checksum manifest, and installs it with APT.
sudo tee /usr/local/bin/update-powershell > /dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
repo_api="https://api.github.com/repos/PowerShell/PowerShell/releases/latest"
cache_parent="${XDG_CACHE_HOME:-$HOME/.cache}/powershell-deb"
arch="$(dpkg --print-architecture)"
if [ "$arch" != "amd64" ]; then
printf 'This helper expects amd64, but this system reports %s.\n' "$arch" >&2
exit 1
fi
mkdir -p "$cache_parent"
tmp_dir="$(mktemp -d "${cache_parent}/download.XXXXXX")"
trap 'rm -rf "$tmp_dir"' EXIT
release_json="$(curl -fsSL "$repo_api")"
version="$(printf '%s' "$release_json" | python3 -c 'import json, sys; print(json.load(sys.stdin)["tag_name"].lstrip("v"))')"
deb_name="powershell_${version}-1.deb_amd64.deb"
base_url="https://github.com/PowerShell/PowerShell/releases/download/v${version}"
deb_url="${base_url}/${deb_name}"
hash_url="${base_url}/hashes.sha256"
printf 'Installing PowerShell %s from %s\n' "$version" "$deb_url"
curl -fsSLo "${tmp_dir}/${deb_name}" "$deb_url"
curl -fsSLo "${tmp_dir}/hashes.sha256" "$hash_url"
printf 'Verifying %s\n' "$deb_name"
(
cd "$tmp_dir"
iconv -f utf-16 -t utf-8 hashes.sha256 | tr -d '\r' | grep "${deb_name}$" | sha256sum -c -
)
sudo apt-get install "${tmp_dir}/${deb_name}" -y
pwsh --version
EOF
sudo chmod 755 /usr/local/bin/update-powershell
Run the helper when you want to install the current GitHub package or refresh an existing 26.04 fallback install:
update-powershell
Installing PowerShell 7.6.1 from https://github.com/PowerShell/PowerShell/releases/download/v7.6.1/powershell_7.6.1-1.deb_amd64.deb Verifying powershell_7.6.1-1.deb_amd64.deb powershell_7.6.1-1.deb_amd64.deb: OK The following NEW packages will be installed: powershell Setting up powershell (7.6.1-1.deb) ... PowerShell 7.6.1
Verify PowerShell on Ubuntu
The Debian package name is powershell, but the command you launch is pwsh. Check the binary path and version after either install method:
command -v pwsh
pwsh --version
/usr/bin/pwsh PowerShell 7.6.1
Start an interactive PowerShell session any time with pwsh. Exit back to your normal shell with exit.
Get Started with PowerShell on Ubuntu
A new shell is not very useful if the first prompt leaves you staring at a blank screen. These short examples show the basic PowerShell workflow on Linux without drifting into Windows-only administration tasks.
Use PowerShell Help
Start with the built-in help system whenever a cmdlet name looks familiar but the syntax does not. PowerShell uses a consistent Verb-Noun naming pattern, so once you know the verb, help is usually the fastest route to the rest.
Get-Help Get-Process
If you want the full local help files later, run Update-Help. For module overviews, platform-specific examples, and official package notes, use Microsoft’s PowerShell installation documentation for Ubuntu.
List Files with PowerShell
Get-ChildItem is the PowerShell equivalent of ls. The difference is that PowerShell returns structured objects instead of plain text, which makes later filtering and formatting easier.
Get-ChildItem
Add -Force to include hidden files and -Recurse to walk subdirectories when you need a deeper listing.
Inspect Processes with PowerShell
Process inspection is a good place to see the object pipeline pay off. This example sorts processes by CPU usage and shows the busiest five entries first.
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5
Because the pipeline passes objects instead of raw text, you can keep chaining filters and property selections without writing brittle column-matching logic.
Search Log Files with PowerShell
Select-String fills the same role as the grep command for quick file searches. It is especially useful when you want to stay inside one PowerShell session instead of mixing shells mid-task.
Get-Content /var/log/apt/history.log | Select-String "Install"
If you want to search a different text log, replace the path with another readable file. For journal-only systems, export the relevant journal entries first and then search the saved text file from PowerShell.
Update or Remove PowerShell on Ubuntu
Update PowerShell from the Microsoft Repository
For Ubuntu 24.04 and 22.04 repository installs, updates flow through APT. Use --only-upgrade when you want to refresh PowerShell without installing it on systems where it is not already present.
sudo apt update && sudo apt install --only-upgrade powershell -y
Update a GitHub Deb Install
A GitHub .deb install does not create an APT repository. If /usr/local/bin/update-powershell exists, refresh PowerShell with one command:
update-powershell
Without the helper, check the PowerShell GitHub releases page for a newer package version, set POWERSHELL_VERSION to that release, then repeat the download, checksum, and local APT install sequence.
Remove PowerShell
Remove the package with APT. Use purge when you want package-owned configuration state removed as well as the executable files:
sudo apt purge powershell -y
Preview dependency cleanup before running autoremove on a reused system. If the preview lists only packages you no longer need, run the real cleanup command.
sudo apt autoremove --dry-run
sudo apt autoremove -y
If you used the Microsoft repository method, delete the PowerShell-specific source and keyring after the package is gone, then refresh APT:
sudo rm -f /etc/apt/sources.list.d/powershell.sources
sudo rm -f /usr/share/keyrings/powershell.gpg
sudo apt update
If you created the GitHub update helper, remove it too:
sudo rm -f /usr/local/bin/update-powershell
hash -r
Confirm the package is no longer installed:
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' powershell 2>/dev/null || echo "powershell absent"
powershell absent
Package removal does not touch user history, user-installed modules, or profile files. A normal PowerShell session writes history to
~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt, and profile files can also live under~/.config/powershell/if you create them.
Remove personal PowerShell files only when you no longer need command history, user modules, or local profile files. Skip this cleanup if you plan to reinstall and keep your personal PowerShell setup.
rm -rf ~/.local/share/powershell ~/.config/powershell
Troubleshoot PowerShell Installation on Ubuntu
Most PowerShell install failures on Ubuntu come down to a release mismatch, a missing signing key, or mixed .NET package sources. Start with the package source and candidate checks before reinstalling the shell.
Fix No PowerShell Candidate in APT
If APT says Unable to locate package powershell or shows Candidate: (none), check the release and package policy together:
lsb_release -rs
lsb_release -cs
apt-cache policy powershell
26.04 resolute powershell: Installed: (none) Candidate: (none)
On Ubuntu 26.04, that result is expected at the moment because Microsoft’s 26.04 repository metadata exists but does not list the powershell package. Use the GitHub .deb fallback. On Ubuntu 24.04 or 22.04, Candidate: (none) usually means the Microsoft source file was not created, the keyring path is wrong, or sudo apt update did not finish cleanly.
Fix PowerShell GPG Key Errors
If APT reports a signature problem, reimport the key and refresh the package lists again. This is the fastest fix when the keyring file is missing, truncated, or points at the wrong path in Signed-By.
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/powershell.gpg
sudo apt update
Fix PowerShell .NET Package Conflicts
Ubuntu 22.04 and newer ship their own .NET packages, which can conflict with the Microsoft feed when you mix both sources. If you want to keep Microsoft’s repository for PowerShell but prefer Ubuntu’s .NET packages, pin Microsoft’s dotnet, aspnet, and netstandard packages out of the way.
printf '%s\n' \
'Package: dotnet* aspnet* netstandard*' \
'Pin: origin "packages.microsoft.com"' \
'Pin-Priority: -10' | sudo tee /etc/apt/preferences.d/99-microsoft-dotnet.pref > /dev/null
sudo apt update
That pin leaves powershell available from Microsoft while lowering priority for Microsoft’s .NET package names. Microsoft’s Ubuntu package-mixup documentation covers the deeper decision tree when your system also installs .NET workloads.
Remove the pin if you later decide to use Microsoft’s .NET packages from the same feed:
sudo rm -f /etc/apt/preferences.d/99-microsoft-dotnet.pref
sudo apt update
Fix PowerShell Launch Failures
If pwsh exits immediately or starts throwing shared library errors after an interrupted upgrade, reinstall the package and check the version again.
sudo apt reinstall powershell -y
pwsh --version
PowerShell 7.6.1
Conclusion
PowerShell on Ubuntu uses the Microsoft APT repository on Ubuntu 24.04 and 22.04, with the official GitHub .deb fallback on Ubuntu 26.04 until the repository package appears there. To round out the same terminal-heavy workflow, install GitHub CLI on Ubuntu for repository tasks or install Visual Studio Code on Ubuntu for editing and debugging your scripts.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>