如何在 AlmaLinux 8 上安装 Powershell

PowerShell Core 是一个运行良好的跨平台(Windows、Linux 和 macOS)自动化和配置工具/框架使用您现有的工具,并针对处理结构化数据(例如 JSON、CSV、XML 等)、REST API 和对象模型进行了优化。它包括一个命令行外壳、一个相关的脚本语言和一个用于处理 cmdlet 的框架。terminal-linux-logo

在 AlmaLinux 8 上安装 Powershell

步骤 1. 首先,让我们先确保您的系统是最新的。

sudo dnf update
sudo dnf install epel-release

步骤 2. 在 AlmaLinux 8 上安装 Snap。

现在我们运行以下命令将 Snap 安装到您的系统:

sudo dnf install snapd

安装完成后,我们需要启用并启动 Snapd 守护进程:

sudo systemctl enable --now snapd.socket
sudo systemctl start --now snapd.socket

要启用经典 snap 支持,请输入以下内容以在和之间创建符号链接:/var/lib/snapd/snap/snap

sudo ln -s /var/lib/snapd/snap /snap

步骤 2. 在 AlmaLinux 8 上安装 PowerShell。

  • 使用 Snap 安装 PowerShell。

使用 snap 安装 PowerShell 的最简单方法如下:

sudo snap install powershell --classic
  • 从 GitHub 安装 PowerShell。

大多数 Linux 发行版现在都正式支持 PowerShell。GitHub 上提供了所有最新的 PowerShell Linux 软件包:

sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-1.centos.8.x86_64.rpm

成功安装后,这是PowerShell的基本用法:

root@idroot ~]# pwsh
PowerShell 7.1.4
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

PS /root># display Cmdlet list (only display 8 lines from the head)
PS /root> (Get-Command)[0..9]
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        cd..
Function        cd\
Function        Clear-Host
Function        Compress-Archive                                   1.2.6      Microsoft.PowerShell.Archive
Function        Configuration                                      2.0.6      PSDesiredStateConfiguration
Function        Expand-Archive                                     1.2.8      Microsoft.PowerShell.Archive
Function        Find-Command                                       2.2.5.4    PowerShellGet
Function        Find-DSCResource                                   2.2.5.4    PowerShellGet
Function        Find-Module                                        2.2.5.4    PowerShellGet
Function        Find-RoleCapability                                2.2.5.4    PowerShellGet

感谢您使用本教程在您的 AlmaLinux 8 系统上安装 Powershell。如需其他帮助或有用信息,我们建议您查看Powershell 官方网站

未经允许不得转载:统信UOS之家 » 如何在 AlmaLinux 8 上安装 Powershell

相关文章