Installing PowerShell on Alpine Linux
All packages are available on our GitHub releases page. After the package is installed, run
pwsh
from a terminal. Run pwsh-preview
if you installed a preview release. Before installing,
check the list of Supported versions below.
Note
PowerShell 7.4 is an in-place upgrade that removes previous versions of PowerShell 7. Preview versions of PowerShell can be installed side-by-side with other versions of PowerShell. If you need to run PowerShell 7.4 side-by-side with a previous version, reinstall the previous version using the binary archive method.
Installation steps
Installation on Alpine is based on downloading tar.gz package from the releases page. The URL to the package depends on the version of PowerShell you want to install.
- PowerShell 7.4.6 -
https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/powershell-7.4.6-linux-musl-x64.tar.gz
- PowerShell 7.2.24 -
https://github.com/PowerShell/PowerShell/releases/download/v7.2.24/powershell-7.2.24-linux-alpine-x64.tar.gz
- PowerShell 7.5-preview.4 -
https://github.com/PowerShell/PowerShell/releases/download/v7.5.0-preview.3/powershell-7.5.0-preview.3-linux-musl-x64.tar.gz
Then, in the terminal, execute the following shell commands to install PowerShell 7.4:
# install the requirements
sudo apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl1.1 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
curl
sudo apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
lttng-ust
# Download the powershell '.tar.gz' archive
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/powershell-7.4.6-linux-musl-x64.tar.gz -o /tmp/powershell.tar.gz
# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/7
# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7
# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/7/pwsh
# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh
# Start PowerShell
pwsh
Uninstall PowerShell
sudo rm -rf /usr/bin/pwsh /opt/microsoft/powershell
PowerShell paths
$PSHOME
is/opt/microsoft/powershell/7/
- The profiles scripts are stored in the following locations:
- AllUsersAllHosts -
$PSHOME/profile.ps1
- AllUsersCurrentHost -
$PSHOME/Microsoft.PowerShell_profile.ps1
- CurrentUserAllHosts -
~/.config/powershell/profile.ps1
- CurrentUserCurrentHost -
~/.config/powershell/Microsoft.PowerShell_profile.ps1
- AllUsersAllHosts -
- Modules are stored in the following locations:
- User modules -
~/.local/share/powershell/Modules
- Shared modules -
/usr/local/share/powershell/Modules
- Default modules -
$PSHOME/Modules
- User modules -
- PSReadLine history is recorded in
~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
The profiles respect PowerShell's per-host configuration, so the default host-specific profiles
exists at Microsoft.PowerShell_profile.ps1
in the same locations.
PowerShell respects the XDG Base Directory Specification on Linux.
Supported versions
Microsoft supports PowerShell until PowerShell reaches end-of-support or the version of Alpine reaches end-of-life.
Docker images containing PowerShell 7.4 and PowerShell 7.5-preview for x64 are available from the Microsoft Artifact Registry for the following versions of Alpine:
- Alpine 3.17 - OS support ends on 2024-11-22
Docker images of PowerShell aren't available for Alpine 3.18, 3.19, and 3.20.
Important
The Docker images are built from official operating system (OS) images provide by the OS distributor. These images may not have the latest security updates. Microsoft recommends that you update the OS packages to the latest version to ensure the latest security updates are applied.
Installation support
Microsoft supports the installation methods in this document. There may be other methods of installation available from other third-party sources. While those tools and methods may work, Microsoft can't support those methods.