在Alpine Linux上安裝PowerShell
所有套件都可在我們的 GitHub 版本 頁面上取得。 安裝套件之後,請從終端機執行 pwsh
。 如果您已安裝預覽版本,請執行 pwsh-preview
。 安裝之前,請先檢查下方支援的版本清單。
注意
PowerShell 7.4 是移除舊版 PowerShell 7 的就地升級。 PowerShell 的預覽版本可以與其他 PowerShell 版本並存安裝。 如果您需要與舊版並存執行 PowerShell 7.4,請使用 二進位封存 方法重新安裝舊版。
安裝步驟
Alpine 上的安裝是以從 發行 頁面下載tar.gz套件為基礎。 套件的 URL 取決於您要安裝的 PowerShell 版本。
- PowerShell 7.4.2 -
https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell-7.4.2-linux-musl-x64.tar.gz
- PowerShell 7.3.12 -
https://github.com/PowerShell/PowerShell/releases/download/v7.3.12/powershell-7.3.12-linux-alpine-x64.tar.gz
- PowerShell 7.2.19 -
https://github.com/PowerShell/PowerShell/releases/download/v7.2.19/powershell-7.2.19-linux-alpine-x64.tar.gz
然後,在終端機中,執行下列殼層命令來安裝 PowerShell 7.3:
# 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.2/powershell-7.4.2-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
卸載 PowerShell
sudo rm -rf /usr/bin/pwsh /opt/microsoft/powershell
PowerShell 路徑
$PSHOME
是/opt/microsoft/powershell/7/
- 設定檔案文稿會儲存在下列位置:
- AllUsersAllHosts -
$PSHOME/profile.ps1
- AllUsersCurrentHost -
$PSHOME/Microsoft.PowerShell_profile.ps1
- CurrentUserAllHosts -
~/.config/powershell/profile.ps1
- CurrentUserCurrentHost -
~/.config/powershell/Microsoft.PowerShell_profile.ps1
- AllUsersAllHosts -
- 模組會儲存在下列位置:
- 使用者模組 -
~/.local/share/powershell/Modules
- 共用模組 -
/usr/local/share/powershell/Modules
- 預設模組 -
$PSHOME/Modules
- 使用者模組 -
- PSReadLine 歷程記錄會記錄於
~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
這些配置檔會遵循 PowerShell 的每個主機組態,因此預設主機特定配置檔存在於 Microsoft.PowerShell_profile.ps1
相同的位置。
PowerShell 遵循 Linux 上的 XDG 基底目錄規格 。
支援的版本
下表列出支援的 PowerShell 版本,以及其支援的 Alpine 版本。 支援這些版本,直到 PowerShell 版本 達到終止支援 為止,或 Alpine 版本 達到生命週期結束為止。
- 圖示 表示仍支援 OS 或 PowerShell 版本
- 圖示 指出該操作系統版本不再支援PowerShell版本
- 圖示 表示我們尚未在該 OS 上完成 PowerShell 測試
- 圖示 表示不支援操作系統或PowerShell版本
- 當操作系統版本和 PowerShell 版本都有 圖示時,支援該組合
Alpine | 7.2 (LTS-previous) | 7.3 | 7.4 (LTS-current) |
---|---|---|---|
3.18 | |||
3.17 | |||
3.16 | |||
3.15 | |||
3.14 |
Alpine 支援下列處理器架構的PowerShell。
Alpine | 7.2 (LTS-current) | 7.3 | 7.4 (LTS-current) |
---|---|---|---|
所有支援的版本 | x64 | x64 | x64 |
PowerShell 尚未使用 Arm 處理器在 Alpine 上進行測試。
安裝支援
Microsoft 支援本檔中的安裝方法。 可能還有其他第三方來源可用的安裝方法。 雖然這些工具和方法可能正常運作,但 Microsoft 無法支援這些方法。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應