How to Install PowerShell on Ubuntu (24.04, 22.04)

Last updated Wednesday, March 11, 2026 11:40 am 8 min read

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, so the supported APT path comes from Microsoft’s package feed. Microsoft also publishes a universal .deb package through GitHub releases. On supported releases, the repository route is the better fit because updates stay inside APT and the commands work the same on both desktop installs and minimal server images.

Microsoft’s repository method applies to Ubuntu 24.04 and 22.04. Microsoft does not yet publish a resolute branch for Ubuntu 26.04, so 26.04 users need the universal .deb package from the PowerShell GitHub releases page until repository support lands.

Install PowerShell on Ubuntu

The Microsoft repository method gives you the supported powershell package and keeps future upgrades inside APT. Start with a system update, install the repo prerequisites, then add the signed Microsoft source.

Update Ubuntu Before Installing PowerShell

Refresh the package index and install any pending upgrades before you add a new repository. That reduces dependency churn and avoids mixing old package metadata with the new Microsoft feed.

sudo apt update && sudo apt upgrade -y

These commands use sudo for the 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, which keeps the install flow consistent with the later APT commands in this workflow.

Install PowerShell Repository Prerequisites

Ubuntu desktop installs usually already have most of these tools, but server, cloud, and minimal images often do not. Install the small prerequisite set first so APT can trust the Microsoft repository and detect the correct Ubuntu release automatically.

sudo apt install ca-certificates curl gpg lsb-release -y
  • ca-certificates lets APT and curl trust Microsoft’s HTTPS endpoints.
  • curl downloads the signing key and is also useful elsewhere if you need the curl command guide.
  • gpg converts the ASCII key into the binary keyring format APT expects.
  • lsb-release reports your Ubuntu version and codename so the repository file points at the correct branch.

Add the Microsoft PowerShell Repository

PowerShell’s supported APT package comes from packages.microsoft.com, so the next step is importing Microsoft’s signing key and creating a DEB822 repository file. DEB822 is the current APT format and fits LinuxCapable’s repository standard better than the older one-line .list style.

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -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.

Now write the Microsoft source file. This uses sudo tee because plain shell redirection with > does not inherit sudo privileges when the destination lives under /etc/apt/.

printf '%s\n' \
"Types: deb" \
"URIs: https://packages.microsoft.com/ubuntu/$(lsb_release -rs)/prod" \
"Suites: $(lsb_release -cs)" \
"Components: main" \
"Architectures: $(dpkg --print-architecture)" \
"Signed-By: /usr/share/keyrings/powershell.gpg" | sudo tee /etc/apt/sources.list.d/powershell.sources > /dev/null

$(lsb_release -rs) expands to 22.04 or 24.04, $(lsb_release -cs) expands to jammy or noble, and $(dpkg --print-architecture) usually returns amd64. Microsoft’s Ubuntu repository uses the version number in the URL path and the codename as the suite, so both substitutions matter.

Refresh APT after the repository file is in place:

sudo apt update
Get:1 https://packages.microsoft.com/ubuntu/24.04/prod noble InRelease [3,600 B]
Get:4 https://packages.microsoft.com/ubuntu/24.04/prod noble/main amd64 Packages [101 kB]
Get:5 https://packages.microsoft.com/ubuntu/24.04/prod noble/main all Packages [643 B]

Those lines confirm APT can reach the Microsoft feed. Check the package candidate before installing it:

apt-cache policy powershell
powershell:
	Installed: (none)
	Candidate: 7.5.4-1.deb
	Version table:
		 7.5.4-1.deb 500
				500 https://packages.microsoft.com/ubuntu/24.04/prod noble/main amd64 Packages

Install PowerShell with APT

Once APT sees the package candidate from Microsoft, install PowerShell like any other repository package:

sudo apt install powershell -y
Get:1 https://packages.microsoft.com/ubuntu/24.04/prod noble/main amd64 powershell amd64 7.5.4-1.deb [75.5 MB]
Setting up powershell (7.5.4-1.deb) ...

Verify PowerShell on Ubuntu

The Debian package name is powershell, but the command you launch is pwsh. Use the version flag first because it is the quickest headless-safe check after installation.

pwsh --version
PowerShell 7.5.4

Ubuntu 22.04 and 24.04 currently pull the same 7.5.4 package. After the version check, start an interactive shell any time with pwsh.

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 and platform-specific examples, the official PowerShell documentation is still the best reference.

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 keep everything inside one PowerShell session instead of mixing shells mid-task.

Get-Content /var/log/syslog | Select-String "error"

If your system does not keep a traditional /var/log/syslog file, swap in another text log such as /var/log/auth.log or export journal output first.

Update or Remove PowerShell on Ubuntu

Update PowerShell

Because PowerShell came from an APT repository, updates flow through the standard package manager. Use --only-upgrade when you want to refresh PowerShell without touching unrelated packages.

sudo apt update && sudo apt install --only-upgrade powershell -y

Remove PowerShell

Start by removing the package and any no-longer-needed dependencies. That leaves your system packages clean before you remove the Microsoft repo metadata.

sudo apt remove powershell -y && sudo apt autoremove -y

After the package is gone, delete the repository file and keyring, then refresh APT:

sudo rm -f /etc/apt/sources.list.d/powershell.sources
sudo rm -f /usr/share/keyrings/powershell.gpg
sudo apt update

Check the package state once the repository has been removed:

apt-cache policy powershell
powershell:
	Installed: (none)
	Candidate: (none)
	Version table:

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.

The next command deletes PowerShell command history, user modules, and any local profile files. Skip it 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 three things: a repo branch that Microsoft has not published yet, a missing signing key, or mixed .NET package sources. These fixes handle the cases most readers run into first.

Fix PowerShell Repository 404 Errors

A 404 from packages.microsoft.com usually means your Ubuntu release does not have a published Microsoft branch yet, or the DEB822 file points to the wrong version or suite.

lsb_release -rs && lsb_release -cs
24.04
noble

A supported repo install currently shows 22.04/jammy or 24.04/noble. If you see 26.04/resolute, Microsoft’s PowerShell repository is not ready yet, so use the universal .deb from the PowerShell GitHub releases page until that branch exists.

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 -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

On Ubuntu 22.04, that pin changes dotnet-runtime-8.0 from the Microsoft build to the Ubuntu security build while leaving powershell available from Microsoft. If you need the deeper decision tree, Microsoft’s Ubuntu package-mixup documentation covers both sides of the .NET choice.

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.5.4

PowerShell on Ubuntu FAQ

Should you use the Microsoft repository or the official PowerShell .deb on Ubuntu?

Use Microsoft’s repository on Ubuntu 22.04 and 24.04 because APT handles upgrades and removal cleanly. The official universal .deb package is mainly the fallback for Ubuntu 26.04 while the resolute repository branch is still missing, or for cases where you intentionally want a manual install.

Does Microsoft’s PowerShell repository support Ubuntu 26.04?

Not yet. Microsoft currently publishes Ubuntu repository metadata for jammy and noble, but the resolute branch returns 404 Not Found. Use the universal .deb package from the PowerShell GitHub releases page on Ubuntu 26.04 until repository support lands.

Why does apt say unable to locate package powershell?

That usually means the Microsoft repository was not added correctly, sudo apt update did not finish cleanly, or you are on an unsupported Ubuntu release. A working setup shows a powershell candidate from packages.microsoft.com when you run apt-cache policy powershell.

Why is the package name powershell but the command is pwsh?

Microsoft keeps the Debian package name as powershell, but the executable is pwsh. After installation, start the shell with pwsh and use pwsh --version for a quick verification check.

Conclusion

PowerShell on Ubuntu is installed from Microsoft’s supported APT feed, so pwsh stays easy to update and remove. 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.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: